apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Hidden category not found by exact name

Open pigsonthewing opened this issue 4 years ago • 10 comments

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.

pigsonthewing avatar Jan 19 '21 11:01 pigsonthewing

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

devarsh-mavani-19 avatar Mar 19 '22 08:03 devarsh-mavani-19

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

nicolas-raoul avatar Mar 19 '22 09:03 nicolas-raoul

  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

sivaraam avatar Mar 19 '22 18:03 sivaraam

Thanks @sivaraam that's indeed much better!

nicolas-raoul avatar Mar 20 '22 00:03 nicolas-raoul

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.

devarsh-mavani-19 avatar Mar 20 '22 11:03 devarsh-mavani-19

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.

nicolas-raoul avatar Mar 20 '22 12:03 nicolas-raoul

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 : )

devarsh-mavani-19 avatar Mar 21 '22 03:03 devarsh-mavani-19

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 🙂

sivaraam avatar Mar 22 '22 18:03 sivaraam