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

[WIP] Refactor feedback and quiz to reduce possibility of NPE #1881

Merged
merged 3 commits into from
Sep 6, 2018

Conversation

maskaravivek
Copy link
Member

Title (required)

Fixes #1876

Description (required)

Fixes #1876

Have refactored some pieces of feedback and quiz to reduce NPE scenario. Have marked the PR as WIP as I have tested it just once and will go through these two modules once again to further handle crash prone cases.

Tests performed (required)

Tested both the achievements and quiz module on Redmi 5.

@maskaravivek maskaravivek changed the base branch from master to 2.8-release September 4, 2018 23:12
@misaochan
Copy link
Member

misaochan commented Sep 5, 2018

Looks good to me, thanks @maskaravivek :) . Happy to merge when it has been completed, pending successful tests.

Please test with:
(1) A normal account with revert rate less than the threshold. Make sure you spend time going around the app and using the features (e.g. upload), as this crash doesn't just pop up immediately after loading Contributions. Personally it tends to pop up for me when choosing pictures to upload. AND
(2) Either an account with revert rate greater than the threshold, or simulating such an account by modifying the values in a debugger. The quiz should trigger, but even if the quiz doesn't, it should fail gracefully, not crash

@codecov-io
Copy link

codecov-io commented Sep 5, 2018

Codecov Report

Merging #1881 into 2.8-release will increase coverage by 0.05%.
The diff coverage is 9.85%.

Impacted file tree graph

@@              Coverage Diff               @@
##           2.8-release   #1881      +/-   ##
==============================================
+ Coverage         3.67%   3.72%   +0.05%     
==============================================
  Files              188     190       +2     
  Lines             9555    9552       -3     
  Branches           846     848       +2     
==============================================
+ Hits               351     356       +5     
+ Misses            9180    9172       -8     
  Partials            24      24
Impacted Files Coverage Δ
.../free/nrw/commons/di/CommonsApplicationModule.java 47.61% <ø> (ø) ⬆️
...ree/nrw/commons/achievements/FeedbackResponse.java 0% <0%> (ø)
...ain/java/fr/free/nrw/commons/quiz/QuizChecker.java 0% <0%> (ø) ⬆️
...fr/free/nrw/commons/achievements/Achievements.java 0% <0%> (ø) ⬆️
...nrw/commons/achievements/AchievementsActivity.java 0% <0%> (ø) ⬆️
.../free/nrw/commons/achievements/FeaturedImages.java 0% <0%> (ø)
.../java/fr/free/nrw/commons/di/NetworkingModule.java 87.5% <100%> (+27.5%) ⬆️
...rw/commons/mwapi/ApacheHttpClientMediaWikiApi.java 3.8% <22.22%> (+0.24%) ⬆️
.../java/fr/free/nrw/commons/auth/SessionManager.java 9.52% <0%> (-0.48%) ⬇️
...in/java/fr/free/nrw/commons/mwapi/CustomMwApi.java 7.86% <0%> (-0.19%) ⬇️
... and 4 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 b584942...c0fa0ad. Read the comment docs.

@neslihanturan
Copy link
Collaborator

I have a question first, does this feature active in beta too? I assume so.

Test 1(beta)- No crash
Test 2(beta)- No crash, to enable quiz reminder I changed calculateRevertParameter method accordingly:
private void calculateRevertParameter() {
if (revertCount==0) {
callQuiz();
return;
}...
}

Now quiz checker dialog is called, but twice... I confirm that it also happens on master, so this PR does its job well.

I couldn't reproduce the crash in either cases.

@misaochan
Copy link
Member

@neslihanturan I would check on prod just to be sure. Not much point checking beta, especially as we're not sure if the revert count API works on beta. You don't need to actually upload bad images on your account, just use the debugger to simulate the revert count values for Test (2).

@neslihanturan
Copy link
Collaborator

Yes, I think we should test on prod indeed.

@maskaravivek
Copy link
Member Author

@misaochan @neslihanturan The PR is ready for review now. :)

@misaochan
Copy link
Member

misaochan commented Sep 6, 2018

Test 1 works for me on prod (Nexus S API 24)!! Spent 10 mins uploading stuff, going to different parts of the app, relogging, etc, and no crash. :)

Test 2... I actually can't seem to get the quiz to trigger via the old debugger method, I guess because the flow has changed. Manually changing the code like @neslihanturan did worked, though.

I will test a bit more to see if this works with the debugger (and @maskaravivek or anyone else with a high revert % from all the old test uploads, would be great if you could test ;)), but am leaning towards merging anyway.

@misaochan misaochan merged commit 6eb01b8 into commons-app:2.8-release Sep 6, 2018
maskaravivek added a commit that referenced this pull request Sep 7, 2018
* Add Traceur for getting meaningful RxJava stack traces (#1832)

* Hotfix for overwrite issue in 2.8.0  (#1838)

* This solution is an hotfix for overrite issue came back on 2.8.0 version. What I did is checking the extension, and if it is null, adding .jpg suffix. Because commons files always have suffixes, and we should compare file names after adding suffixes. Othervise overrides are possible.

* Check if file title includes an extension already, by checking if is there any dot in it.

* Fix logic error

* Add uncovered tests

* Remove unecessary line breaks

* Make Javadocs more explicit

* Versioning and changelog for v2.8.2 (#1842)

* Versioning for v2.8.2

* Changelog for v2.8.2

* Add logs in wiki data edit and session refresh flow (#1874)

* Fix logout (#1875)

* [WIP] Refactor feedback and quiz to reduce possibility of NPE (#1881)

* Refactor feedback and quiz to reduce possibility of NPE

* Handle throwables in quiz checker

* Minor refactoring

* Set Traceur to only work in DEBUG mode (#1884)

* Bug fix for uploaded images count in achievements activity (#1885)

* Versioning and changelog for v2.8.3 (#1886)

* Update changelog.md

* Versioning for v2.8.3
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.

4 participants