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

1776 validate show total validations #2029

Merged
merged 17 commits into from
May 29, 2020

Conversation

kumararoosh
Copy link
Collaborator

resolves #1776 by querying the database for all completed validation missions by the current user and adding the amount of labels validated in those missions to the displayed label count.

Changed the label from the amount of labels completed in the current mission to how labels completed in one stretch, by using svv.misisonsCompleted

TODO: change svv.missionsCompleted to store the amount of missions the user has completed in all time
Queried the database for the total completed validations for each user, and got the data to be available in Mission.js
Changed the label in validate to show the total number of validations performed by the current user
Made the label count correct for the first time the validation page loads
Fixed a bug that would change the value of the labels completed during the mission end screen
@misaugstad
Copy link
Member

@kumararoosh could you provide before/after screenshots?

@kumararoosh
Copy link
Collaborator Author

Pre:
Show all labels validated pre

Post:
sho wall labels validated post

@misaugstad
Copy link
Member

Looks like you're only including validations from completed missions. I don't see any reason to only take the ones from completed missions. May as well include all missions? This also means that since you are only using the completed mission count, you are assuming that all missions include 10 labels. That is true right now, but may not always be true in the future.

Changed countCompletedValidationMissionsByUserID in MisstionTable.scala
to count all of the validated labels instead of counting all of the
validated missions.
Edited all of the files responsible for displaying the amount of
validations performed by the user, to instead use the total number of
labels validated instead of total number of validation missions
completed.
@kumararoosh
Copy link
Collaborator Author

The number of labels validated is now the total number of labels the user has validated

Copy link
Member

@misaugstad misaugstad 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 on fixing up the backend! It looks really nice and clean and works well now! Just looking for some cleaning up of the frontend portion now :)

if (labelsProgress < getProperty("labelsValidated")) {
if (!skip) {
labelsProgress += 1;
}
svv.statusField.updateLabelCounts(labelsProgress);
var missionLabelNumber = labelsProgress + svv.validationsCompleted;
Copy link
Member

Choose a reason for hiding this comment

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

This seems like kind of a messy way to keep track of the number of completed validations. What if instead of recomputing it every time, the statusField object just kept track of the count, and then when a label is validated, a function is called that increments that count?

@@ -83,12 +85,19 @@ function Mission(params) {
* progress will increase.
*/
function updateMissionProgress(skip) {
// console.log(getProperties());
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you want me to uncomment it, or just delete the line?

Copy link
Member

Choose a reason for hiding this comment

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

Just delete the line

The label is updated by taking the number being displayed to the user
and incrementing the number. Added a helper function in StatusField to
help with the incrementing.
@kumararoosh
Copy link
Collaborator Author

I believe everything has been cleaned up now

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

I think you may have missed a couple places where you added code for counting completed missions that you don't need.

* Increments the number of labels the user has validated by 1
*/
function incrementLabelCounts(){
updateLabelCounts(parseInt(svv.ui.status.labelCount.html()) + 1);
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 it would be better for this file to have a variable that saves the current validation count instead of looking at the HTML to find it. Then updateLabelCounts can update that variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm now using the existing svv.validationsCompleted variable to store the total number of validations completed

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think it is best to just never have that global variable. You can pass in param.completedValidations to the StatusField constructor and save the variable locally in the StatusField object.

Since the total completed validations is stored in
svv.validationsCompleted when loaded from the database, the labels now
just displays the value of svv.validationsCompleted and increments the
variable each time a validation is made.
@kumararoosh
Copy link
Collaborator Author

Made requested changes

svv.missionsCompleted = param.missionSetProgress;
svv.validationsCompleted = param.completedValidations;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of saving this in a global variable (svv.validationsCompleted) you should pass in param.completedValidations to the StatusField constructor and save the variable locally in the StatusField object.

Started storing the value of total completed validations in StatusField
by passing it in as a parameter, and changed updating to requiring the
increment and refresh methods be called in StatusField
@kumararoosh
Copy link
Collaborator Author

I am now passing the total validations to statusField and requiring everything else to call the new incrementLabelCounts and refreshLabelCountsDisplay methods inside of statusField in order to manipulate the statusField. Should we then update the javaDoc for statusField on how it should manipulate the displayed value?

@misaugstad
Copy link
Member

I guess so? Not exactly sure what you're envisioning. The setup seems pretty simple and you've added comments for the methods, so not sure what else you're proposing we add

Removed updateLabelCount and every use of the function. The new process
for updating the labels is to send the value to statusField as a
parameter and call refreshLabelCountsDisplay() or incrementLabelCounts()
@kumararoosh
Copy link
Collaborator Author

This branch should be completed now

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

Again, just some super nitpicky comment style stuff. You'll get used to our code style soon! Then just make sure to triple check before asking for reviews to make sure everything looks nice :)

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

Great, thanks @kumararoosh !

@misaugstad misaugstad merged commit eb76d5f into develop May 29, 2020
@misaugstad misaugstad deleted the 1776-validate-show-total-validations branch May 29, 2020 23:35
@misaugstad misaugstad mentioned this pull request Jun 10, 2020
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.

2 participants