Skip to content

Feedback Module: Add reverts rate parameter #1649

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 8 commits into from
Jul 4, 2018

Conversation

tanvidadu
Copy link
Contributor

Added Reverts Parameter to FeedBack Module

Fixes #85

Description (required)

Refactored mwApi to fetch count of images reverted
Refactored LevelController and Achievements to add the number of reverts as a parameter.

Tests performed (required)

Tested on BetaDebug and ProdDebug

Screenshots showing what changed (optional)

{Only for user interface changes, otherwise remove this section. See how to take a screenshot}

Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.

@codecov-io
Copy link

codecov-io commented Jun 21, 2018

Codecov Report

Merging #1649 into feedback-gamification will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@                   Coverage Diff                    @@
##           feedback-gamification   #1649      +/-   ##
========================================================
- Coverage                   3.04%   3.01%   -0.04%     
========================================================
  Files                        140     140              
  Lines                       7683    7761      +78     
  Branches                     720     721       +1     
========================================================
  Hits                         234     234              
- Misses                      7434    7512      +78     
  Partials                      15      15
Impacted Files Coverage Δ
...nrw/commons/achievements/AchievementsActivity.java 0% <0%> (ø) ⬆️
...fr/free/nrw/commons/achievements/Achievements.java 0% <0%> (ø) ⬆️
...n/java/fr/free/nrw/commons/auth/LoginActivity.java 0% <0%> (ø) ⬆️
...free/nrw/commons/achievements/LevelController.java 0% <0%> (ø) ⬆️
...rw/commons/mwapi/ApacheHttpClientMediaWikiApi.java 4.98% <0%> (-0.25%) ⬇️
.../java/fr/free/nrw/commons/auth/SessionManager.java 15.38% <0%> (-1.29%) ⬇️

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 bd1555f...ad46087. Read the comment docs.

@tanvidadu
Copy link
Contributor Author

@misaochan @maskaravivek pr is ready for review!

@misaochan
Copy link
Member

misaochan commented Jun 23, 2018

Hi @tanvidadu , thanks for the PR. Looks good to me in general, but unfortunately I can't actually test this until Vivek fixes the API so it can retrieve the deletion rate for my account. So we will have to wait for that before we merge, I think.

Are you able to carry on working on the quiz/tutorial in the meantime?

@tanvidadu
Copy link
Contributor Author

Yes! since both are separate modules I will continue with quiz/tutorial :)

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

misaochan commented Jul 1, 2018

Just tested this, works perfectly for me! Great job, @tanvidadu ! :) (And also, this tells me that I need to work on reducing my deletion percentage, lol).

Just one final suggestion (and then I think we can merge and wrap up Phase 1 of your project, if @maskaravivek agrees) - what do you think about having 'i' icons next to each parameter for a brief description? This will allow us to keep the main text simple while explaining the statistics more clearly to users.

My thoughts on how the final texts could look like, with information text in italics:

  • Images uploaded (The number of images you have uploaded to Commons, via any upload software)
  • Images not deleted (The percentage of images you have uploaded to Commons that were not deleted)
  • Images used (The number of images you have uploaded to Commons that were used in Wikimedia articles)

@misaochan
Copy link
Member

Oops, there also seems to be a bug with the levelling, when I tested with my secondary account (Misaochan2). According to the stats, I should have levelled up, because all 3 requirements are fulfilled. There might be an error with the revert rate checking for levelling up?

device-2018-07-01-191219

@tanvidadu
Copy link
Contributor Author

@misaochan small error on my part :( I have fixed the bug
I think its a great idea to 'i' next to each parameter.
Below is the mock of the screen after adding 'i'

@commons-app commons-app deleted a comment Jul 1, 2018
@misaochan
Copy link
Member

@tanvidadu My suggestion is to have the 'i's in a different color from the text, in blue perhaps? :)

Thanks for fixing the bug, I will re-test once the information tooltips are completed.

Copy link
Member

@maskaravivek maskaravivek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @tanvidadu. Changes look good to me. Have just added a few minor comments. :)

try {
achievements.setRevertCount(object.getInt("deletedUploads"));
} catch (JSONException e) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Timber logs here. :)

.observeOn(AndroidSchedulers.mainThread())
.subscribe(
object -> parseJsonRevertCount(object)
));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a throwable subscription too.

*/
private void setRevertCount(){
compositeDisposable.add(mediaWikiApi
.getRevertCount(sessionManager.getCurrentAccount().name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can sessionManager.getCurrentAccount() ever return a null? If yes, add a null check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't return a null till logging in mandatory :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the java docs for this method. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maskaravivek this kind of check?
Optional.ofNullable(sessionManager.getCurrentAccount().name.orElse("")
It requires min API 24 where as min API of Commons app is 15. Any idea how to go about it ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple null check like this should be enough.

Account currentAccount = sessionManager.getCurrentAccount();
if(currentAccount == null) {
// do something
}

Recently we experienced a few crashes on play store and we suspect that getCurrentAccount is returning null in some cases even for logged in users.

Refer to this PR for more context:
https://github.com/commons-app/apps-android-commons/pull/1684/files

* used to set the non revert image percentage
* @param notRevertPercentage
*/
private void setImageRevertPercentage( int notRevertPercentage){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove whitespace. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find white spaces here but throughout the code, I tried to remove all extra white spaces :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he means the extra whitespace between ( and int ;)

In general it's a good idea to follow the style of existing code. For instance, observe the places there are whitespaces (and no whitespaces) here:
public void onCreate(Bundle savedInstanceState) {

Locale.ENGLISH,
fetchRevertCountUrlTemplate,
new PageTitle(userName).getText());
String userNameCaps = Character.toString(userName.charAt(0)).toUpperCase()+userName.substring(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually required? MediaWiki usernames always start with a capital letter. Our shared prefs should already have username in this format.

https://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(technical_restrictions)#Lowercase_first_letter

@commons-app commons-app deleted a comment Jul 1, 2018
Copy link
Member

@misaochan misaochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadocs requested

@@ -1,5 +1,7 @@
package fr.free.nrw.commons.achievements;

import android.util.Log;

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadocs are spotty for this class, please have a more descriptive Javadoc here, and add them to all the new methods as well. Thanks! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misaochan I have updated the javadocs :)

@commons-app commons-app deleted a comment Jul 2, 2018
@misaochan
Copy link
Member

Thanks @tanvidadu . :) Are we ready for me to re-test this?

@tanvidadu
Copy link
Contributor Author

Yes! @misaochan thanks :)

@misaochan
Copy link
Member

Works for me now, well done @tanvidadu ! :)

@misaochan misaochan merged commit 12fb75a into commons-app:feedback-gamification Jul 4, 2018
maskaravivek pushed a commit that referenced this pull request Jul 26, 2018
*  Implemented Statistics

*  Basic Structure Implemented

*  Layout made screen independent and menu inflated

*  Share Screenshot using cache

*  Improved the Image Bound and added strings

*  Improved the quality of Pr

*  Wired to navigation drawer

*  Changed the bounds of the image

*  Added Info icon

* Removed the unecessary functionality

*  Updated JavaDocs and fetch the username

*  Fetch JsonObject from the api using JavaRx and OkHttp

* Added JavaDocs and improved quality

* fixed strings file

*  Improved the quality of pr

*  Render thanks , images used in articles on screen

*  fetch and rendered the upload count

*  FeaturedImages statistics rendered and Javadocs added

*  added ProgressBar

*  Added Class for calculating level

*  added level info and returned level info

*  level up info rendered on achievement activity

*  Inflated Level Number

*  Added the structure for badge

*  Added LevelUpInfo Programmetically on Drawable

*  aligned the text

*  changed the text

*  Implemented the structure for changing colour of drawable

*  Added functionality to change colours of badge during runtime

*  Added custom alert for share option

*  Improved the UI of screen

*  Added the alertDialog for info button

*  Improved the quality of PR

*  Added Builder model

*  Added Enum Model and increased levels to 15

* removed redundant class

*  Changed strings and added subtext

* Feedback Module: Add reverts rate parameter (#1649)

* Fetched Revert Count

* Refactored Achievements class and display the fetched results

* Refactored the levelController to include revert as parameter

*  Fixed error

*  Fixed bug

*  Added information for parameters and improved code quality

*  Javadocs added

*  Added null check and javadocs

*  Removed extra spaces
@tanvidadu tanvidadu deleted the feedback3 branch August 3, 2018 13:46
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