Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude nominated media #2858

Closed

Conversation

silkypriya
Copy link
Contributor

Description
Not showing media that have been nominated for deletion in Explore's Uploaded via mobile tab.

Fixes #2658 In "Uploaded via mobile", hide media nominated for deletion

What changes did you make and why?
Getting wikitext of media using API:Parse and filtering that have been nominated for deletion.

Tests performed
Tested betaDebug on Realme 2 pro (Android Version 8.1.0) with API level 27.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
Only a few minor style/javadoc improvements left :-)

@@ -74,14 +74,14 @@ public MediaWikiApi provideMediaWikiApi(Context context,
public OkHttpJsonApiClient provideOkHttpJsonApiClient(OkHttpClient okHttpClient,
@Named("tools_force") HttpUrl toolsForgeUrl,
@Named("default_preferences") JsonKvStore defaultKvStore,
Gson gson) {
Gson gson,MediaWikiApi mediaWikiApi) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please insert a space after each comma, thanks! :-)

return new OkHttpJsonApiClient(okHttpClient,
toolsForgeUrl,
WIKIDATA_SPARQL_QUERY_URL,
BuildConfig.WIKIMEDIA_CAMPAIGNS_URL,
BuildConfig.WIKIMEDIA_API_HOST,
defaultKvStore,
gson);
gson,mediaWikiApi);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since each parameter is on its own line, I would suggest doing the same for mediaWikiApi.

@@ -316,6 +317,17 @@ public String prependEdit(String editToken, String processedPageContent, String
.getString("/api/flow-parsoid-utils/@content"));
}

@Override
@NonNull
public String getWikiText(PageTitle title) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc explaining (in just a few words) what wikitext is, to avoid misunderstandings.

@@ -67,14 +69,15 @@ public OkHttpJsonApiClient(OkHttpClient okHttpClient,
String campaignsUrl,
String commonsBaseUrl,
JsonKvStore defaultKvStore,
Gson gson) {
Gson gson,MediaWikiApi mediaWikiApi) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

own line

e.printStackTrace();
}

if(!wikiText.contains("{{delete")){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable :-)

if(!wikiText.contains("{{delete")){
mediaList.add(media);
}
} else mediaList.add(media);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest putting that into its own

{
    ...
}

block, to improve visibility, even if not required by the Java language.

Per https://google.github.io/styleguide/javaguide.html#s4.1.1-braces-always-used (which is linked to from https://github.com/commons-app/apps-android-commons/wiki/Contributing-Guidelines )

@@ -105,4 +107,8 @@
interface ProgressListener {
void onProgress(long transferred, long total);
}

@NonNull
String getWikiText(PageTitle title) throws IOException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need a new API to check if the page has been nominated for deletion.

Checkout MediaDataExtractor. It uses:

        Single<Boolean> pageExistsSingle = mediaWikiApi.pageExists("Commons:Deletion_requests/" + filename);

@@ -330,7 +333,19 @@ public OkHttpJsonApiClient(OkHttpClient okHttpClient,
for (MwQueryPage page : pages) {
Media media = Media.from(page);
if (media != null) {
mediaList.add(media);
if(keyword.equals("Category:Uploaded_with_Mobile/Android")){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special case handling for Category:Uploaded_with_Mobile/Android category should not be the responsibility of OkHttpJsonApiClient. Please add this check in CategoryImageController.

https://github.com/commons-app/apps-android-commons/blob/master/app/src/main/java/fr/free/nrw/commons/category/CategoryImageController.java

@@ -58,6 +59,7 @@
private final String commonsBaseUrl;
private final JsonKvStore defaultKvStore;
private Gson gson;
private MediaWikiApi mediaWikiApi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't reference MediaWikiApi from this class. It already has commonsBaseUrl which can be used to build a new HttpUrl to call a commons MediaWiki API.

@neslihanturan
Copy link
Collaborator

Thanks a lot for this PR @silkypriya . This Pr is requested some changes by reviewers, but seems inactive for long time.Can you inform us will you be able to do them?

@domdomegg
Copy link
Member

Closing stale PR for now, reopen if more work happening on it.

@domdomegg domdomegg closed this Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants