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

Generalised Review System, complete email functionality #5387

Merged
merged 8 commits into from
Aug 14, 2018

Conversation

nithusha21
Copy link
Contributor

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

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes.
  • The PR explanation includes the words "Fixes #bugnum: ...".
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

@codecov-io
Copy link

codecov-io commented Jul 29, 2018

Codecov Report

❗ No coverage uploaded for pull request base (develop@a80bd6d). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            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.

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

Copy link
Contributor

@anmolshkl anmolshkl left a 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!

if len(suggestions) > 0:
reviewer_id = suggestion_services.get_next_user_in_rotation(
score_category)
print reviewer_id
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (
get_all_scores_of_user(
suggestion.author_id)[suggestion.score_category] >=
feconf.MINIMUM_SCORE_REQUIRED_TO_REVIEW):
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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

get_all_scores_of_user(
suggestion.author_id)[suggestion.score_category] >=
feconf.MINIMUM_SCORE_REQUIRED_TO_REVIEW):
# Send email if not sent already.
Copy link
Contributor

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?

Copy link
Contributor Author

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):
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as #5387 (comment)

@oppiabot
Copy link

oppiabot bot commented Aug 6, 2018

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!

@anmolshkl
Copy link
Contributor

@nithusha21 we need to move quickly on all our PRs otherwise we risk leaving everything for the last minute.

Copy link
Contributor

@anmolshkl anmolshkl left a comment

Choose a reason for hiding this comment

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

@nithusha21 lgtm!

@@ -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(
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

score = (
user_models.UserContributionScoringModel.get_score_of_user_for_category(
user_id, score_category))
if not score:
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 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".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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 had made some errors here. Added a test for these 2 functions and verified behavior. Also changed names

@@ -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.
Copy link
Member

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".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

score_category))

next_user_id = None
if not position_tracking_model:
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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)
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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:
Copy link
Member

Choose a reason for hiding this comment

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

if instance is None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@nithusha21
Copy link
Contributor Author

PTAL @seanlip

Copy link
Member

@seanlip seanlip left a 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?

@nithusha21
Copy link
Contributor Author

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.

@seanlip
Copy link
Member

seanlip commented Aug 13, 2018

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!

@seanlip seanlip merged commit 994ac33 into oppia:develop Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants