Skip to content

Make P18 edits to corresponding wikidata entity on uploading from Nearby #1495

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

Merged
merged 22 commits into from
May 31, 2018

Conversation

maskaravivek
Copy link
Member

Description

Fixes part of #252 ie. "Edit P18 property in Wikidata to add the uploaded image"

Tests performed

Tested on a real android phone by uploading an image from the list of nearby places needing pictures.

  • Uploaded a picture
  • Opened the wikidata entity to check if the image got associated
  • Refreshed the nearby list, the item no longer shows 🎉

Note: After performing the test I have gone back to the entity and removed the image as I used a random image for testing.

Screenshots showing what changed

The GIF was too big so had to upload elsewhere: https://imgur.com/a/qCfFgv5

@misaochan misaochan changed the title Log P18 edits to wikidata corresponding wikidata entity on uploading … Make P18 edits to wikidata corresponding wikidata entity on uploading … May 6, 2018
@misaochan misaochan changed the title Make P18 edits to wikidata corresponding wikidata entity on uploading … Make P18 edits to corresponding wikidata entity on uploading from Nearby May 6, 2018
@misaochan
Copy link
Member

Hi @maskaravivek , thanks for the PR! I will test this ASAP, in the meantime could you please create a feature branch and send this PR to it instead of master, as we need to have logging done before this can be merged with master.

Also, it would be great if we could get Javadocs for the new methods. :)

@maskaravivek maskaravivek changed the base branch from master to wikidataEdits May 6, 2018 19:05
@maskaravivek
Copy link
Member Author

@misaochan I have updated the PR with requested changes. :)

@codecov-io
Copy link

codecov-io commented May 6, 2018

Codecov Report

Merging #1495 into wikidataEdits will decrease coverage by 0.02%.
The diff coverage is 1.88%.

Impacted file tree graph

@@               Coverage Diff                @@
##           wikidataEdits   #1495      +/-   ##
================================================
- Coverage           3.13%    3.1%   -0.03%     
================================================
  Files                136     138       +2     
  Lines               7412    7496      +84     
  Branches             716     721       +5     
================================================
+ Hits                 232     233       +1     
- Misses              7165    7248      +83     
  Partials              15      15
Impacted Files Coverage Δ
...nrw/commons/notification/NotificationActivity.java 0% <ø> (ø) ⬆️
.../fr/free/nrw/commons/nearby/NearbyMapFragment.java 0% <0%> (ø) ⬆️
...rc/main/java/fr/free/nrw/commons/nearby/Place.java 0% <0%> (ø) ⬆️
...a/fr/free/nrw/commons/upload/UploadController.java 0% <0%> (ø) ⬆️
...java/fr/free/nrw/commons/upload/UploadService.java 0% <0%> (ø) ⬆️
...e/nrw/commons/location/LocationServiceManager.java 0% <0%> (ø) ⬆️
...mmons/contributions/ContributionsListFragment.java 0% <0%> (ø) ⬆️
...ava/fr/free/nrw/commons/nearby/NearbyActivity.java 0% <0%> (ø) ⬆️
.../commons/contributions/ContributionController.java 0% <0%> (ø) ⬆️
...r/free/nrw/commons/contributions/Contribution.java 0% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 677f85a...bce3b17. Read the comment docs.

translatewiki and others added 4 commits May 7, 2018 07:54
* Integrate API for displaying featured images

* Add pagination and refactor code so that it can be reused for category images

* Add license info to the images

* Fix author view

* Remove unused values

* Fix minor issues with featured images

* Fix null license url issue

* Remove some log lines

* Fix back navigation issue

* fix tests

* fix test inits

* Gracefully handling various error situations

* Added java docs
* Update pull_request_template.md

* Remove Javadocs mention

* Added required/optional notes
@neslihanturan
Copy link
Collaborator

Team, before testing this PR I want to make sure that, even if while we are on betaDebug, if we upload a photo via nearby, then it will be uploaded to real servers. Am I correct? So to test this we might need to take a photo of nearby place:)

@nicolas-raoul
Copy link
Member

nicolas-raoul commented May 7, 2018

I just built (in prodDebug flavor) from https://github.com/maskaravivek/apps-android-commons/tree/wikidata then ran, opened Nearby and tapped on the pin for https://www.wikidata.org/wiki/Q30297420 then pressed "Gallery" and selected a photo of the thing, then modified slightly the prefilled description and entered metadata as usual before tapping the floppy icon.

Unfortunately, the Wikidata item does not seem to have got any edit: https://www.wikidata.org/w/index.php?title=Q30297420&action=history
The image has been uploaded successfully though: https://commons.wikimedia.org/wiki/File:Building_that_hosts_the_Salt_Science_Research_Foundation.jpg

* Intent to map added

*  Merge conflicts resolved

*  Added the functionality to hide FAB incase of null coordinate

*  Merge Conflict resolved

*  Improve pr quality

* Improve Quality

*  Added nested FAB animations

* Nested FAB implemented

*  Improve Quality

*  Added up arrow

*  Javadocs Added
@misaochan
Copy link
Member

@neslihanturan The image will be uploaded to the beta server I believe, but the Wikidata edit will be real. Either way, we should use prodDebug for testing. Either by taking real photos of Nearby places, or by uploading a test photo and then deleting. We discussed how to delete Wikidata edits on #252 . :)

* Add dependency for MaterialShowcase

* Add actionview class to get a reference to material showcase

* Create a NearbyMaterialShowcaseSequence class

* Apply sequence steps

* Add first three steps of nearby showcase

* Add sequence id constants to make sure they will be displayed only once

* Add last step of sequence to explain plus fab

* Create an object to prevent customize all sequences every time

* Fix typo

* Code cleanup

* Add strings to strings.xml

* Code cleanup

* Revert irrelevant change

* Revert irrelevant change

* Remove showcaseview for recenter button

* Use single showcaseView instead of sequence

* Add single showcase view insted of sequence to be able to edit text style

* Make sure it will be displayed only once

* Cleanup

* Update strings

* Change dismiss text style
@maskaravivek
Copy link
Member Author

@nicolas-raoul Am sorry, that the wiki data edit didn't work for you as expected.
Right now I am handling the error silently if the edit call fails. Do you think that some error toast should be displayed if the edit fails?

I will also add some more logs so that debugging error cases becomes easier.

sivaraam and others added 2 commits May 8, 2018 09:34
…pp#1453)

* CONTRIBUTING: fix formatting of the gist of the guidelines

First level headings for a gist seems to be overkill.

So, replace first level headings with an ordered-list which
sounds more meaningful.

* CONTRIBUTING: specify clearly that 'blame' is a feature of "Git"

The contributing file specifies about the ability to know who wrote
something without the need of @author javadoc tags but incorrectly
attributes the feature to GitHub.

Correctly attribute the feature to where it belongs, Git, and specify
the name of the feature to help users easily take advantage of it.
* Implemented butterknife in MediaDetailFragment [issue commons-app#1491]

* Implemented butterknife in MediaDetailPagerFragment [[issue commons-app#1491]]

* post merge upstream master wip [[issue commons-app#1491]]
@misaochan
Copy link
Member

misaochan commented May 8, 2018

Hi @maskaravivek , I experienced a few strange bugs while testing this.

My steps:

  1. Uploaded a bogus picture for https://www.wikidata.org/wiki/Q19817749 . After the upload went through, the picture was actually added to the P18 claim, yay! However, Nearby did not reflect the change - the pin did not disappear even after I refreshed it. It did disappear after I exited the app and relaunched it, though.
  2. Deleted bogus picture.
  3. Uploaded a proper picture for https://www.wikidata.org/wiki/Q5355155 . After the upload went through, I checked the P18 claim on that item, nothing was added. However, then I checked the first Wikidata item (Q19817749) again, and the picture was there instead!
  4. So if you look at Q19817749 now, the edit history shows 2 images added. The first image was intended for that item, and the second image was actually uploaded via Q5355155 but ended up in Q19817749 instead.

It is also worth noting that I am still editing anonymously, was the central auth already implemented?

P.S. Nice work with the Javadocs! It is way easier to read through and understand the code now. :)

* Bug fix commons-app#1504

* Filtered messages with ConnectException [issue commons-app#1504]

* A generalised message for exceptions in Nearby Activity [issue commons-app#1504]
@maskaravivek
Copy link
Member Author

@misaochan Thanks for helping with testing. :)

  • Now I have added listeners so the nearby map should refresh immediately after the edit is made.
  • I am unable to reproduce the issue where every time the edit is being made for a single wikidata entity.

Have yet not figured out how to add authentication for these edits. :(

translatewiki and others added 2 commits May 14, 2018 08:13
@misaochan
Copy link
Member

misaochan commented May 15, 2018

@maskaravivek Are you able to upload at all after your recent changes? All of my uploads fail with the error logs below. Both Nearby direct uploads as well as the usual uploads from the main screen, with different images. I have logged out and logged back in again twice, with neither one fixing the issue.

Also, I think you may need to rebase commons-app:wikidataEdits on master, as there are several changes not authored by you in the commit history here. :) Which makes it difficult to debug the source of the failure.

05-15 19:20:09.982 21597-21628/fr.free.nrw.commons.debug E/WTF: Result: org.mediawiki.api.ApiResult@3afe3a9
05-15 19:20:10.024 21597-21628/fr.free.nrw.commons.debug E/ApacheHttpClientMediaWi: mustbeloggedin
05-15 19:21:04.764 21597-21597/fr.free.nrw.commons.debug E/ViewRootImpl: sendUserActionEvent() mView == null
05-15 19:21:17.943 21597-21597/fr.free.nrw.commons.debug E/ViewRootImpl: sendUserActionEvent() mView == null
05-15 19:22:28.330 21597-21628/fr.free.nrw.commons.debug E/WTF: Result: org.mediawiki.api.ApiResult@cffc3d
05-15 19:22:28.352 21597-21628/fr.free.nrw.commons.debug E/ApacheHttpClientMediaWi: mustbeloggedin

@nicolas-raoul
Copy link
Member

I just clone Vivek's repo, switch to the "wikidataEdits" branch, switched to prodDebug, ran the app, touched Nearby, selected a nearby pin, touched the "+", select a picture, touched the upload button, and the floppy.
The image was uploaded successfully but the selected Wikidata item still has no P18.
Am I doing something wrong?

@misaochan
Copy link
Member

@nicolas-raoul I don't think there is any "wikidataEdits" branch in Vivek's repo. :) Are you perchance testing the wikidataEdits branch of commons-app instead? That would explain why it isn't working for you, since this PR hasn't been merged into commons-app:wikidataEdits yet. To test this PR, I am using git fetch commons-app pull/1495/head:pr-1495.

@nicolas-raoul
Copy link
Member

@misaochan Thanks, I cloned the right repo+branch now :-)
Same problem happens, though, the upload was successful but the image is still not linked to from Wikidata.

@misaochan
Copy link
Member

misaochan commented May 15, 2018

@neslihanturan , we need you to test and see if either my or Nicolas's problems are reproducible. :) I think it should be fine to upload a bogus picture on prodDebug and then manually delete the p18 link on Wikidata (and if the picture doesn't belong on Commons at all, nominate your own picture for deletion and mention in the comments that you are testing). But if you are really concerned about it, you can use the sandbox entity mentioned at #252 .

@maskaravivek maskaravivek force-pushed the wikidata branch 2 times, most recently from e6c71cd to b8e213e Compare May 18, 2018 18:21
@maskaravivek
Copy link
Member Author

@misaochan I am able to make authenticated edits now.

https://www.wikidata.org/w/index.php?title=Q13406268&action=history

Yes, I am also facing an issue while uploading/making edits if I install this build over a previously installed version but logging out and logging in again solves it for me. Could you share some logs that might help in detecting the issue?

Anyone who is testing the PR can skip the whole upload flow and check just the edits if they wish. Paste this snippet in any of the activities and trigger it on its start. Might be helpful while we are debugging various issues.

private void edit() {
        Timber.d("Attempting to edit Wikidata property %s", "Q13406268");
        Observable.fromCallable(() -> mediaWikiApi.wikidatCreateClaim("Q13406268", "P18", "value", "\"Hamburg,_Speicherstadt,_Wasserschloss_--_2016_--_2944-50.jpg\""))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(result -> {
                    if(result) {
                        ViewUtil.showLongToast(getBaseContext(), "Image added corresponding to wiki data entity successfully!");
                    } else {
                        Timber.d("Unable to make wiki data edit for entity %s", "Q13406268");
                    }
                }, throwable -> Timber.e(throwable, "Error occurred while making claim"));
    }

@maskaravivek
Copy link
Member Author

@nicolas-raoul I have added logs that might help us identify why the edits are failing for you. Would it be possible for you to retry and share the logs?

@misaochan
Copy link
Member

misaochan commented May 23, 2018

Hi @maskaravivek ,

I just retested this on my real device running Android 7.0. It works!!! Well done!! 👍 Uploading a picture added the P18 entity appropriately to https://www.wikidata.org/wiki/Q19876257 and https://www.wikidata.org/wiki/Q14935526 (I will delete those later). The Wikidata edits are also authenticated for me. Excellent work.

A few minor issues:

  • After the upload completes, there is a toast that notifies the user and the map refreshes (great!), but the point is still displayed then. It continues to be displayed until I manually relaunch the activity. I guess it may be caused by the points being cached. I'm not sure how easy it will be to fix this bug - it's possible that re-adding refresh functionality to Nearby may be the easiest short term fix.
  • I personally feel that the toast is not very non-tech-user friendly. How about something like: "Image successfully added to [entity name] on Wikidata!"?

@misaochan
Copy link
Member

@maskaravivek I'm happy to go ahead and merge this since @neslihanturan is experiencing issues with her VPN. If there are problems later we can solve them in a different PR.

Please sort out the minor changes requested, then I can merge. :)

@maskaravivek
Copy link
Member Author

@misaochan

  • I tried uploading an image and the nearby list updated instantly for me without having to go back.
  • Fetching the entity name will require another API call as the wbcreateclaim response doesn't contain the entity name. Can we avoid the API call?

@misaochan
Copy link
Member

misaochan commented May 30, 2018

I tried uploading an image and the nearby list updated instantly for me without having to go back.

Hmm, that has never happened for me, I always need to manually reload Nearby. But I guess we can merge this PR first and then debug this issue later since it isn't a major one.

Have addressed the second point in Hangouts. :)

@maskaravivek
Copy link
Member Author

@misaochan I have made the change suggested by you.

Yes, let's merge this first and then we can debug this issue.

@commons-app commons-app deleted a comment May 30, 2018
@misaochan
Copy link
Member

Thanks @maskaravivek ! Can't wait to release this feature. :)

@misaochan misaochan merged commit 4815e93 into commons-app:wikidataEdits May 31, 2018
@maskaravivek maskaravivek deleted the wikidata branch September 12, 2018 20:25
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.

10 participants