Use JSON version 2 API for MwQueryResponse responses (#2816)

This commit is contained in:
Adam Jones 2019-04-01 19:03:30 +01:00 committed by Vivek Maskara
parent 01696ccc0e
commit 23c23cc9fc
3 changed files with 16 additions and 6 deletions

View file

@ -238,6 +238,7 @@ public class OkHttpJsonApiClient {
.newBuilder()
.addQueryParameter("action", "query")
.addQueryParameter("format", "json")
.addQueryParameter("formatversion", "2")
.addQueryParameter("titles", titles);
if (useGenerator) {
@ -293,7 +294,8 @@ public class OkHttpJsonApiClient {
.parse(commonsBaseUrl)
.newBuilder()
.addQueryParameter("action", "query")
.addQueryParameter("format", "json");
.addQueryParameter("format", "json")
.addQueryParameter("formatversion", "2");
if (queryType.equals("search")) {
@ -408,6 +410,7 @@ public class OkHttpJsonApiClient {
.newBuilder()
.addQueryParameter("action", "query")
.addQueryParameter("format", "json")
.addQueryParameter("formatversion", "2")
.addQueryParameter("list", "recentchanges")
.addQueryParameter("rcstart", DateUtils.formatMWDate(startDate))
.addQueryParameter("rcnamespace", FILE_NAMESPACE)
@ -442,6 +445,7 @@ public class OkHttpJsonApiClient {
.newBuilder()
.addQueryParameter("action", "query")
.addQueryParameter("format", "json")
.addQueryParameter("formatversion", "2")
.addQueryParameter("prop", "revisions")
.addQueryParameter("rvprop", "timestamp|ids|user")
.addQueryParameter("titles", filename)

View file

@ -13,7 +13,7 @@ import fr.free.nrw.commons.media.model.MwQueryPage;
public class MwQueryResult {
@SuppressWarnings("unused")
@Nullable
private HashMap<String, MwQueryPage> pages;
private List<MwQueryPage> pages;
private List<RecentChange> recentchanges;
@NonNull
@ -21,7 +21,7 @@ public class MwQueryResult {
if (pages == null) {
return new ArrayList<>();
}
return new ArrayList<>(pages.values());
return pages;
}
public List<RecentChange> getRecentchanges() {