-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Generalised Review System, complete email functionality #5387
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5387 +/- ##
=========================================
Coverage ? 46.3%
=========================================
Files ? 500
Lines ? 29275
Branches ? 4452
=========================================
Hits ? 13557
Misses ? 15718
Partials ? 0 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nithusha21 took the first pass. PTAL, thanks!
core/controllers/cron.py
Outdated
if len(suggestions) > 0: | ||
reviewer_id = suggestion_services.get_next_user_in_rotation( | ||
score_category) | ||
print reviewer_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop the print statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/domain/suggestion_services.py
Outdated
if ( | ||
get_all_scores_of_user( | ||
suggestion.author_id)[suggestion.score_category] >= | ||
feconf.MINIMUM_SCORE_REQUIRED_TO_REVIEW): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just need to send the email once the user crosses this threshold, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we need to add the user to the reviewer's list at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, the reviewer list is actually dynamically generated here https://github.com/oppia/oppia/pull/5387/files#diff-1d286750bff5aba07f586681357b8024R431
The model just stores the "index" we are at
core/domain/suggestion_services.py
Outdated
get_all_scores_of_user( | ||
suggestion.author_id)[suggestion.score_category] >= | ||
feconf.MINIMUM_SCORE_REQUIRED_TO_REVIEW): | ||
# Send email if not sent already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it yet to be completed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return [data.score_category for data in query_set] | ||
|
||
|
||
class ReviewerRotationTrackingModel(base_models.BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when (and where) do you add entries to the list in this model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as #5387 (comment)
Hi @nithusha21. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
@nithusha21 we need to move quickly on all our PRs otherwise we risk leaving everything for the last minute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nithusha21 lgtm!
core/domain/suggestion_services.py
Outdated
@@ -258,6 +259,23 @@ def reject_suggestion(suggestion, reviewer_id, review_message): | |||
feedback_services.create_message( | |||
suggestion.suggestion_id, reviewer_id, | |||
feedback_models.STATUS_CHOICES_IGNORED, None, review_message) | |||
if feconf.ENABLE_RECORDING_OF_SCORES: | |||
increment_score_for_user( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we incrementing scores when we reject a suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I think I misplaced this call. My bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/domain/suggestion_services.py
Outdated
score = ( | ||
user_models.UserContributionScoringModel.get_score_of_user_for_category( | ||
user_id, score_category)) | ||
if not score: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is misnamed. Typically, a score should be a number. It shouldn't have a "has email been sent" property.
So: scoring_model_instance perhaps, and get_model_of_user_for_category (instead of get_score_...). Ditto elsewhere.
And then here: use "if score is None".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had made some errors here. Added a test for these 2 functions and verified behavior. Also changed names
core/domain/suggestion_services.py
Outdated
@@ -317,6 +336,40 @@ def check_user_can_review_in_category(user_id, score_category): | |||
return score >= feconf.MINIMUM_SCORE_REQUIRED_TO_REVIEW | |||
|
|||
|
|||
def check_if_email_has_been_sent_to_user(user_id, score_category): | |||
"""Checks if user has already recieved an email. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling, here and below: "received".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/domain/suggestion_services.py
Outdated
score_category)) | ||
|
||
next_user_id = None | ||
if not position_tracking_model: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if position_tracking_model is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/domain/suggestion_services.py
Outdated
there are reviewers for the given category. Else None. | ||
""" | ||
reviewer_ids = get_all_user_ids_who_are_allowed_to_review(score_category) | ||
reviewer_names = user_services.get_usernames(reviewer_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just sort by reviewer IDs? I don't see the need for converting to reviewer names...
Also, user IDs are guaranteed to be immutable. User names may change (in the future). Use the stable identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... ok. I'll do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
""" | ||
instance = cls.get_by_id(score_category) | ||
|
||
if not instance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if instance is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
PTAL @seanlip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (I think). Only looked at it briefly, but confirmed all comments appear to have been addressed.
Has this gone through full e2e manual testing?
Hmmm, I haven't tested it manually, but I did write down backend tests for the functions added. I have verified that the Rotation tracking model works correctly, along with the scoring models. |
OK-- we should make a plan for full e2e testing of this, but approving in the meantime. Feel free to merge when Travis passes. Thanks! |
Explanation
This PR completes the email code, including finding the next reviewer in cycle, and adding a cron job to mail this user. The actual calls to the functions to email the user have not been written yet as it depends on #5245. I will update the PR after that.
PTAL @anmolshkl
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.