<commit_before>package com.uservoice.uservoicesdk.model;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.uservoice.uservoicesdk.rest.Callback;
import com.uservoice.uservoicesdk.rest.RestTaskCallback;

public class Topic extends BaseModel {
	private String name;
	private int numberOfArticles;
	
	public static void loadTopics(final Callback<List<Topic>> callback) {
		doGet(apiPath("/topics.json"), new RestTaskCallback(callback) {
			@Override
			public void onComplete(JSONObject object) throws JSONException {
				callback.onModel(deserializeList(object, "topics", Topic.class));
			}
		});
	}
	
	public static void loadTopic(int topicId, final Callback<Topic> callback) {
		doGet(apiPath("/topics/%d.json", topicId), new RestTaskCallback(callback) {
			@Override
			public void onComplete(JSONObject object) throws JSONException {
				callback.onModel(deserializeObject(object, "topic", Topic.class));
			}
		});
	}
	
	@Override
	public void load(JSONObject object) throws JSONException {
		super.load(object);
		name = getString(object, "name");
		numberOfArticles = object.getInt("article_count");<commit_msg>Only load topics that have articles<commit_after>package com.uservoice.uservoicesdk.model;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.uservoice.uservoicesdk.rest.Callback;
import com.uservoice.uservoicesdk.rest.RestTaskCallback;

public class Topic extends BaseModel {
	private String name;
	private int numberOfArticles;
	
	public static void loadTopics(final Callback<List<Topic>> callback) {
		doGet(apiPath("/topics.json"), new RestTaskCallback(callback) {
			@Override
			public void onComplete(JSONObject object) throws JSONException {
				List<Topic> allTopics = deserializeList(object, "topics", Topic.class);
				List<Topic> topicsWithArticles = new ArrayList<Topic>(allTopics.size());
				for (Topic topic : allTopics) {
					if (topic.getNumberOfArticles() > 0)
						topicsWithArticles.add(topic);
				}
				callback.onModel(topicsWithArticles);
			}
		});
	}
	
	public static void loadTopic(int topicId, final Callback<Topic> callback) {
		doGet(apiPath("/topics/%d.json", topicId), new RestTaskCallback(callback) {
			@Override
			public void onComplete(JSONObject object) throws JSONException {
				callback.onModel(deserializeObject(object, "topic", Topic.class));
			}
		});
	}
	
	@Override
	public void load(JSONObject object) throws JSONException {
		super.load(object);
		name = getString(object, "name");
		numberOfArticles = object.getInt("article_count");
{'fraction_non_alphanumeric': 0.11098398169336385, 'fraction_numerical': 0.00038138825324180017, 'mean_word_length': 5.290167865707434, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3870082', 'n_tokens_mistral': 885, 'n_tokens_neox': 811, 'n_words': 175}