Steps to reproduce:


Hi Nicolas,
I tried to load structured-data branch in Android studio but I could not see this in the list of branches displayed. Am I missing something?

I tried to locally download the code using Git Bash from my forked repo but that was not successful too. The branch does not seem to get listed on my forked repo as well
$ git clone --single-branch --branch structured-data https://github.com/vvijayalakshmi21/apps-android-commons
Cloning into 'apps-android-commons'...
warning: Could not find remote branch structured-data to clone.
fatal: Remote branch structured-data not found in upstream origin

Does that mean I have to load the branch from the main repo?
You have to create a branch in your local repo that tracks structure-data
Then create a sub-branch to it for each pull request.
Maybe try this? https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch
@vvijayalakshmi21 You can also try this:
# Add new remote for the upstream repo which contains `structured-data` branch
# Can be skipped if a remote already exists
git remote add upstream https://github.com/commons-app/apps-android-commons
# Fetch the branches present in the `upstream` remote
git fetch upstream
# Checkout a local branch that tracks the remote's structured-data branch
git checkout -b structured-data upstream/structured-data
# Your local branch which tracks the structured-data branch should be checked out now
# You can try building an app and checking if it works
# After some testing. Create another branch for your fix with a name of your choice
git checkout -b fix-issue-3526
Hi @nicolas-raoul I started to debug the depicts code and for some time the Images were displaying for Items but soon after, I started seeing the default barcode image for Items too despite changing nothing but just introducing more debug points. Not sure if this is something relevant to this issue but could this be because of unstable response?
Also, I was checking the below code snippets for analysis.


I noticed that when we type in bow and press enter, the debugger goes inside the below snippet:
return depictsInterface.getImageForEntity(entityId)
.map(commonsFilename -> {
String name;
But it does not go in when we click Items and directly goes to .singleOrError();
I saved the variable states on debugging the function for bow and items.
value not retrieved.txt
value retrieved.txt
Am I going in the right direction?
I think the issue is with the entity id being entityId = "y/Q186476" format rather than entityId = "Q186476" as seen in the cases where we are able to successfully get the information.
I tried a quick fix (not sure if this is right though) where I removed the y/ prefix as below:
if (entityId.startsWith("y/")){
entityId = entityId.substring(2);
}
Now I see images being displayed for child classes:

wow congratulations, nice find!
Even if substring fixes the bug, I am sure you will agree that instead, creating a valid entityId in the first place would be a better solution.
Where does this entityId come from? Why does it include extra characters before the Q? Can you fix it? Thanks :-)
Hi @nicolas-raoul
The problem is with the getChildQIDs() in OkHttpJsonApiClient.java file.
From the response the entityId = "http://www.wikidata.org/entity/Q186476"
But we are trying to fetch the ID as below:
String entityId = binding.getSubclass().getValue(); ---> has value "http://www.wikidata.org/entity/Q186476"
entityId = entityId.substring(entityId.lastIndexOf("/") - 1); ---> has value "y/Q186476"
For fetching the parent QID in the same file, we are using the below line of code:
entityId = entityId.substring(entityId.lastIndexOf("/") + 1);
Wonderful!
Please send a pull request fixing that :-)
@sivaraam thanks for the info. I followed the steps outlined in your reply and I was able to set up tracking the structured-data branch.
I will make the changes and commit it using a new sub-branch.
Thanks so much for your guidance.
@nicolas-raoul I think fixing this will only fetch the image urls
I checked the output after changing the - to + and the below is the screenshot:

The description is still not displayed although it gets displayed when we search for the same through Explore->Items

I will check the description part and commit the changes together if thats okay?
Or would you suggest committing changes separately?
@sivaraam thanks for the info. I followed the steps outlined in your reply and I was able to set up tracking the structured-data branch.
I will make the changes and commit it using a new sub-branch.
Glad to be of help :)
Thanks so much for your guidance.
My pleasure.
I will check the description part and commit the changes together if thats okay?
Or would you suggest committing changes separately?
@vvijayalakshmi21 Don't be too hesitant to commit your changes. Feel free to commit often. It's good to have several revisions of the code that work. They would only help you get back to a previous working code easily when things go awry. That's one of the main points of committing changes, isn't it?
Here's a related article: Do your commits pass this simple test? - DEV Community 👩💻👨💻
Hi @nicolas-raoul I have been trying to locate where we are fetching the description field for the "Items". I can see that we are making a call in getMediaListFromSearch() and getting the values in the response
2020-04-01 15:42:11.317 25493-25581/fr.free.nrw.commons.beta D/OkHttp: <-- 200 https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&formatversion=2&generator=search&gsrwhat=text&gsrnamespace=6&prop=imageinfo&iiprop=url|extmetadata&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gsrsearch=bow&gsrlimit=10 (621ms)
2020-04-01 15:42:11.836 25493-25564/fr.free.nrw.commons.beta D/OkHttp: {"searchinfo":{"search":"bow"},"search":[{"repository":"local","id":"Q46311","concepturi":"http://www.wikidata.org/entity/Q46311","title":"Q46311","pageid":48453,"url":"//www.wikidata.org/wiki/Q46311","label":"bow","description":"ranged weapon system consisting of an elastic launching device and long-shafted projectiles","match":{"type":"label","language":"en","text":"bow"}},
I think we have not made that call for the child entities once the user clicks on an item from Items. Is my analysis right so far?
The sub classes for an item are fetched by the URL:
The parent classes are fetched using the URL:
https://query.wikidata.org/sparql?query=SELECT%20%3FparentClass%20%3FparentClassLabel%20WHERE%20%7B%0A%20%20%20%20wd%3AQ186476%20wdt%3AP279%20%3FparentClass.%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D%0A&format=json
These are the outputs we get:
get_parent_q_id_response.txt
get_child_q_id_response.txt
As these do not include the description for the child classes and parent classes as well, they are not being displayed. I believe we need to make a call like we do for Items to fetch the description details. What are your thoughts on this?
Thanks for the investigation!
Please send a first pull request for thumbnails only.
Descriptions can be a second pull request later.
To get descriptions, you will need to modify the SPARQL query template to include ?parentClassDescription (or similar for subclass) as seen in this screenshot, in app/src/main/resources/queries/parentclasses_query.rq and app/src/main/resources/queries/subclasses_query.rq:

Hi @nicolas-raoul
I've created a PR from my branch for the thumbnail fix.
I've received an automatic reply asking for testing. Kindly let me know what I need to do to complete the pr process
Unit tests would be required if this was about merging a new feature into master, but for this issue it is OK, don't worry.
Looking forward for a pull request about the description :-)
Hi @nicolas-raoul I have created a PR for fetching description from the server and displaying it for Parent and Child classes where available.


Please have a look and let me know if the changes are fine,
Looks great!
The source code is also good.
Just rebase to fix the conflict, and I will merge :-)
Both fixes merged, thanks @vvijayalakshmi21 ! :-)
Hi @nicolas-raoul can you please assign the next issue? Or can I work on the tooltip one mentioned by @misaochan
@vvijayalakshmi21 I assigned the tooltip issue to you. If you want a different one it is OK too.