-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 Milestone 2: Cron job to automatically accept suggestions after a threshold #5155
Conversation
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 added a few comments, PTAL!
core/domain/feedback_services.py
Outdated
@@ -178,6 +183,19 @@ def create_message( | |||
new_status = thread.status | |||
thread.put() | |||
|
|||
# We do a put on the suggestion linked to the thread, if any so that the |
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.
Perhaps - We do a put on the suggestion linked (if it exists) to the thread so that the....
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/feedback_services.py
Outdated
@@ -178,6 +183,19 @@ def create_message( | |||
new_status = thread.status | |||
thread.put() | |||
|
|||
# We do a put on the suggestion linked to the thread, if any so that the | |||
# last_updated time changes to show that there is activity in the thread. |
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.
How would registering an activity on the thread help?
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.
So my idea was that we accept suggestions which have no activity on them. By activity I mean any conversation basically. So if someone messages on a feedback thread linked to a suggestion, I want to update the last updated time of the suggestion too. Does this clarify the question?
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.
Adding on... If people are discussing about a suggestion, we don't want to auto-approve it right? If no one is discussing, and no action is being taken, then we can safely assume no activity is there and then we can accept the 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.
Yep, that makes sense. Thanks!
@@ -225,3 +225,9 @@ def test_get_suggestions_by_target_id(self): | |||
.get_suggestions_by_target_id( | |||
suggestion_models.TARGET_TYPE_EXPLORATION, 'exp_invalid')), | |||
0) | |||
|
|||
def test_get_all_stale_suggestions(self): | |||
with self.swap(suggestion_models, 'THRESHOLD_TIME_BEFORE_ACCEPT', 0): |
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.
Um we can do better. When we say 0, we are actually not testing the logic which takes a time delta and subtracts it from the current time. It is also fine if the delay is a few msecs only.
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.
so you mean put about 10 msec or something like that instead of 0?
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 added a separate test that checks with the actual value and returns an empty list. This makes sure that the subtraction logic works fine. Is this fine?
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.
Well, unless you are asserting the actual time calculated, you won't know if it is correct or not. One way to verify could be to retrieve a suggestion just before that calculated time or you could abstract that functionality into a method and test that method separately.
@@ -72,6 +74,12 @@ | |||
# The delimiter to be used in score category field. | |||
SCORE_CATEGORY_DELIMITER = '.' | |||
|
|||
# Threshold time after which suggestion is considered stale and auto-accepted. | |||
THRESHOLD_TIME_BEFORE_ACCEPT = 14 * 24 * 60 * 60 * 1000 |
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.
Are we running this weekly or bi-weekly?
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 am actually not sure.. Open for your opinion here. It feels weird that I put the threshold as 14 days while the cron job runs weekly. I think weekly is good? (If so i'll make this 7*....) What do you say?
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.
Made it weekly. If you feel otherwise, we'll change it.
Codecov Report
@@ Coverage Diff @@
## develop #5155 +/- ##
===========================================
- Coverage 47.49% 47.27% -0.22%
===========================================
Files 441 457 +16
Lines 25537 26671 +1134
Branches 4019 4162 +143
===========================================
+ Hits 12129 12609 +480
- Misses 13408 14062 +654
Continue to review full report at Codecov.
|
core/controllers/cron.py
Outdated
def get(self): | ||
"""Handles get requests.""" | ||
suggestions = suggestion_services.get_all_stale_suggestions() | ||
print suggestions |
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 should drop 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
@@ -72,6 +74,12 @@ | |||
# The delimiter to be used in score category field. | |||
SCORE_CATEGORY_DELIMITER = '.' | |||
|
|||
# Threshold time after which suggestion is considered stale and auto-accepted. | |||
THRESHOLD_TIME_BEFORE_ACCEPT = 7 * 24 * 60 * 60 * 1000 |
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.
Name of constant should include units.
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. I added MSECS. I checked other locations and they had it in the short form too. MILLISECONDS would make the variable name too big I feel :)
THRESHOLD_TIME_BEFORE_ACCEPT = 7 * 24 * 60 * 60 * 1000 | ||
|
||
# The default message to be shown when accepting stale suggestions. | ||
DEFAULT_SUGGESTION_ACCEPT_MESSAGE = 'Accepting suggestion due to inactivity.' |
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.
Message is not clear -- whose inactivity?
"Automatically accepting suggestion after X days." would be better. Make sure X is a named constant which gets interpolated and that it is also used in THRESHOLD_TIME_BEFORE_ACCEPT.
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
@@ -63,7 +63,7 @@ def create_suggestion( | |||
if target_type == suggestion_models.TARGET_TYPE_EXPLORATION: | |||
thread_id = feedback_services.create_thread( | |||
target_id, None, author_id, description, | |||
DEFAULT_SUGGESTION_THREAD_SUBJECT) | |||
DEFAULT_SUGGESTION_THREAD_SUBJECT, True) |
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 an arg has a default value, the name of the arg should be specified in caller functions. /cc @apb7 @kevinlee12
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/controllers/cron.py
Outdated
@acl_decorators.can_perform_cron_tasks | ||
def get(self): | ||
"""Handles get requests.""" | ||
suggestions = suggestion_services.get_all_stale_suggestions() |
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.
Add a boolean flag in feconf (ENABLE_AUTO_ACCEPT_OF_SUGGESTIONS) that's set to False by default. We'll turn it on to True for the deployment. But I think we should have a mechanism to turn this off easily if we see issues in practice.
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.
Hi @seanlip, could you take another pass on this PR? |
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.
Thanks! Looks fine from codeowner perspective.
@@ -112,6 +112,12 @@ indexes: | |||
- name: exploration_id | |||
- name: last_updated | |||
|
|||
- kind: GeneralSuggestionModel | |||
properties: | |||
- name: deleted |
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.
not sure why "deleted" is in here? If you remove this stanza and rerun on dev server, does this get autogenerated exactly the way it is now?
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.
This was auto generated. Will try again and let you know.
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.
Just confirmed. So I deleted these lines, and ran the cron job and these lines got added back. Looking around this file a few of the other models also had "deleted". But I have no idea on why "deleted" is being added here.
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.
Hm OK, no idea either. But happy to merge! Thanks for confirming.
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.
Thanks!
…pt suggestions after a threshold (#5155) * added cron job to accept suggestions weekly * fixed linting * updated last_updated field whenever a message is sent to the thread * linting fixed * review changes * linting fixes and minor change * remove print * review changes
Explanation
This PR implements a cron job that will accept all suggestions which were last updated before a threshold time (i.e. no activity has occurred on them).
PTAL @anmolshkl. Thanks!
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.