commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
1k stars 1.18k forks source link

Hidden category not found by exact name #4192

Open pigsonthewing opened 3 years ago

pigsonthewing commented 3 years ago

I apply a location-and-date category such as [[Category:United Kingdom photographs taken on 2021-01-19]] to all my images.

Presumably because these are hidden categories, they are not found by the app's category search.

In settings, please provide an option to have hidden categories found on the category search page (alternatively, please provide the option on that search page, so that it can be activated on an image-by-image basis).

If neither of these is possible please provide the option to enter the category name manually.

devarsh-mavani-19 commented 2 years ago

@nicolas-raoul do u recommend providing this option in settings or on the category selection screen or both?

nicolas-raoul commented 2 years ago

Category search is already very buggy (in part because of server-side issues) so I am hesitant to add settings to it, as settings tend to slow down bug resolution (because different people experience different behaviors).

"please provide the option to enter the category name manually"

That sounds reasonable. Even for non-hidden categories, sometimes typing the exact category name does not make it appear in search (presumably because the API does not like some characters such as parenthesis).

So, an enhancement would be, each time a string is entered or modified in the upload wizard's category search dialog:

  1. Perform the API search call (already implemented)
  2. Perform a second API call to check whether the typed string is the exact name of an already existing category. It could be as crude as calling https://commons.wikimedia.org/w/api.php?action=parse&page=Category:Rabbits&prop=wikitext&formatversion=2 and checking whether this returns an error or not. Error case: https://commons.wikimedia.org/w/api.php?action=parse&page=Category:This_category_does_not_exist&prop=wikitext&formatversion=2
sivaraam commented 2 years ago
  1. Perform a second API call to check whether the typed string is the exact name of an already existing category. It could be as crude as calling https://commons.wikimedia.org/w/api.php?action=parse&page=Category:Rabbits&prop=wikitext&formatversion=2 and checking whether this returns an error or not. Error case: https://commons.wikimedia.org/w/api.php?action=parse&page=Category:This_category_does_not_exist&prop=wikitext&formatversion=2

I'm wondering if you would really need to invoke the parse action. Wouldn't it be more relevant to just use the query action without any of the local filtering that we do?

Success: https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=categoryinfo&titles=Category%3ARabbits

Error: https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=categoryinfo&titles=Category%3AThis_category_does_not_exist

nicolas-raoul commented 2 years ago

Thanks @sivaraam that's indeed much better!

devarsh-mavani-19 commented 2 years ago

Thanks @sivaraam that's indeed much better!

  1. Perform a second API call to check whether the typed string is the exact name of an already existing category. It could be as crude as calling https://commons.wikimedia.org/w/api.php?action=parse&page=Category:Rabbits&prop=wikitext&formatversion=2 and checking whether this returns an error or not. Error case: https://commons.wikimedia.org/w/api.php?action=parse&page=Category:This_category_does_not_exist&prop=wikitext&formatversion=2

I'm wondering if you would really need to invoke the parse action. Wouldn't it be more relevant to just use the query action without any of the local filtering that we do?

Success: https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=categoryinfo&titles=Category%3ARabbits

Error: https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=categoryinfo&titles=Category%3AThis_category_does_not_exist

If I understood correctly, Lets suppose that the text entered in search bar matches a category (hidden), then in that case we should shown it in suggestion box right? If true then won't it be difficult for users as they still have to manually type in category name, rather than us providing suggestions?

Please correct me if I am wrong.

nicolas-raoul commented 2 years ago

After performing API calls 1 and 2, you would concatenate the results:

devarsh-mavani-19 commented 2 years ago

After performing API calls 1 and 2, you would concatenate the results:

  • Result of API call 2 (if not an error) as the first suggestion.
  • Results of API call 1 as the rest of the suggestions.

ok got it thanks. @sivaraam would u like to work on this? if not I will. Thanks : )

sivaraam commented 2 years ago

ok got it thanks. @sivaraam would u like to work on this? if not I will. Thanks : )

You could feel free to work on it 🙂

nicolas-raoul commented 3 weeks ago

@devarsh-mavani-19 Did you get a chance to check my comment on your pull request at https://github.com/commons-app/apps-android-commons/pull/4924#issuecomment-1740375551 ? :-)

nicolas-raoul commented 2 weeks ago

@devarsh-mavani-19 I unassign for now, but if you are you still working on this, please let us know. If no answer, someone else may be assigned to it. Thanks a lot. :-)