Hidden categories are not showed in suggested categories (#3853)

This commit is contained in:
Paulina 2020-07-19 10:29:29 -05:00 committed by GitHub
parent 8630ba8025
commit 67beb947c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -92,8 +92,9 @@ class CategoryClient @Inject constructor(private val categoryInterface: Category
it.query()?.pages() ?: emptyList()
}
.map {
it.map { page -> page.title().replace(CATEGORY_PREFIX, "") }
it.filter {
page -> page.categoryInfo() == null || !page.categoryInfo().isHidden
}.map { page -> page.title().replace(CATEGORY_PREFIX, "") }
}
}
}

View file

@ -32,7 +32,7 @@ public interface CategoryInterface {
* @return
*/
@GET("w/api.php?action=query&format=json&formatversion=2"
+ "&generator=allcategories")
+ "&generator=allcategories&prop=categoryinfo")
Single<MwQueryResponse> searchCategoriesForPrefix(@Query("gacprefix") String prefix,
@Query("gaclimit") int itemLimit, @Query("gacoffset") int offset);

View file

@ -22,6 +22,7 @@ public class MwQueryPage extends BaseModel {
@SuppressWarnings("unused") private int ns;
@SuppressWarnings("unused") private int index;
@SuppressWarnings("unused,NullableProblems") @NonNull private String title;
@SuppressWarnings("unused,NullableProblems") @NonNull private CategoryInfo categoryinfo;
@SuppressWarnings("unused") @Nullable private List<LangLink> langlinks;
@SuppressWarnings("unused") @Nullable private List<Revision> revisions;
@SuppressWarnings("unused") @Nullable private List<Coordinates> coordinates;
@ -42,6 +43,10 @@ public class MwQueryPage extends BaseModel {
return title;
}
@NonNull public CategoryInfo categoryInfo() {
return categoryinfo;
}
public int index() {
return index;
}
@ -185,6 +190,17 @@ public class MwQueryPage extends BaseModel {
}
}
public static class CategoryInfo {
@SuppressWarnings("unused") private boolean hidden;
@SuppressWarnings("unused") private int size;
@SuppressWarnings("unused") private int pages;
@SuppressWarnings("unused") private int files;
@SuppressWarnings("unused") private int subcats;
public boolean isHidden() {
return hidden;
}
}
static class Thumbnail {
@SuppressWarnings("unused") private String source;
@SuppressWarnings("unused") private int width;