mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Skip used images (#5160)
* Only Review Images That Has No Usage * Coding Standard Related Changes * Coding Standard Changes - 1 * small change
This commit is contained in:
parent
b917fe3229
commit
496933654b
6 changed files with 109 additions and 5 deletions
|
|
@ -25,6 +25,8 @@ public class MwQueryPage extends BaseModel {
|
|||
@SuppressWarnings("unused,NullableProblems") @NonNull private CategoryInfo categoryinfo;
|
||||
@SuppressWarnings("unused") @Nullable private List<LangLink> langlinks;
|
||||
@SuppressWarnings("unused") @Nullable private List<Revision> revisions;
|
||||
@SuppressWarnings("unused") @SerializedName("fileusage") @Nullable private List<FileUsage> fileUsages;
|
||||
@SuppressWarnings("unused") @SerializedName("globalusage") @Nullable private List<GlobalUsage> globalUsages;
|
||||
@SuppressWarnings("unused") @Nullable private List<Coordinates> coordinates;
|
||||
@SuppressWarnings("unused") @Nullable private List<Category> categories;
|
||||
@SuppressWarnings("unused") @Nullable private PageProps pageprops;
|
||||
|
|
@ -67,6 +69,14 @@ public class MwQueryPage extends BaseModel {
|
|||
return categories;
|
||||
}
|
||||
|
||||
@Nullable public List<GlobalUsage> globalUsages() {
|
||||
return globalUsages;
|
||||
}
|
||||
|
||||
@Nullable public List<FileUsage> fileUsages() {
|
||||
return fileUsages;
|
||||
}
|
||||
|
||||
@Nullable public List<Coordinates> coordinates() {
|
||||
// TODO: Handle null values in lists during deserialization, perhaps with a new
|
||||
// @RequiredElements annotation and corresponding TypeAdapter
|
||||
|
|
@ -141,6 +151,28 @@ public class MwQueryPage extends BaseModel {
|
|||
title += "#" + fragment;
|
||||
}
|
||||
|
||||
public boolean checkWhetherFileIsUsedInWikis() {
|
||||
if (globalUsages != null && globalUsages.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fileUsages == null || fileUsages.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int totalCount = fileUsages.size();
|
||||
|
||||
/* Ignore usage under https://commons.wikimedia.org/wiki/User:Didym/Mobile_upload/
|
||||
which has been a gallery of all of our uploads since 2014 */
|
||||
for (final FileUsage fileUsage : fileUsages) {
|
||||
if ( ! fileUsage.title().contains("User:Didym/Mobile upload")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Revision {
|
||||
@SerializedName("revid") private long revisionId;
|
||||
private String user;
|
||||
|
|
@ -228,6 +260,44 @@ public class MwQueryPage extends BaseModel {
|
|||
}
|
||||
}
|
||||
|
||||
public static class GlobalUsage {
|
||||
@SerializedName("title") private String title;
|
||||
@SerializedName("wiki")private String wiki;
|
||||
@SerializedName("url") private String url;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getWiki() {
|
||||
return wiki;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class FileUsage {
|
||||
@SerializedName("pageid") private int pageid;
|
||||
@SerializedName("ns") private int ns;
|
||||
@SerializedName("title") private String title;
|
||||
|
||||
public int pageId() {
|
||||
return pageid;
|
||||
}
|
||||
|
||||
public int ns() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
public String title() {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Category {
|
||||
@SuppressWarnings("unused") private int ns;
|
||||
@SuppressWarnings("unused,NullableProblems") @Nullable private String title;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class MwQueryResponse extends MwResponse {
|
|||
|
||||
@SuppressWarnings("unused") @SerializedName("continue") @Nullable private Map<String, String> continuation;
|
||||
|
||||
@Nullable private MwQueryResult query;
|
||||
@SerializedName("query") @Nullable private MwQueryResult query;
|
||||
|
||||
public boolean batchComplete() {
|
||||
return batchComplete;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
public class MwQueryResult extends BaseModel implements PostProcessingTypeAdapter.PostProcessable {
|
||||
@Nullable private List<MwQueryPage> pages;
|
||||
@SerializedName("pages") @Nullable private List<MwQueryPage> pages;
|
||||
@Nullable private List<Redirect> redirects;
|
||||
@Nullable private List<ConvertedTitle> converted;
|
||||
@SerializedName("userinfo") private UserInfo userInfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue