-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add meta-review to gamification #190
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gamification/process/update.py
Outdated
@@ -10,6 +10,7 @@ | |||
from gamification.labels import NEGATIVE_POINT_LABELS | |||
from gamification.data.points import MERGE_REQUEST_CLOSED_WITHOUT_MERGE | |||
from gamification.models import Participant | |||
from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear |
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.
The code does not comply to PEP8.
Origin: PEP8Bear, Section: all.python.default
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpllcuiaks/gamification/process/update.py
+++ b/tmp/tmpllcuiaks/gamification/process/update.py
@@ -10,7 +10,7 @@
from gamification.labels import NEGATIVE_POINT_LABELS
from gamification.data.points import MERGE_REQUEST_CLOSED_WITHOUT_MERGE
from gamification.models import Participant
-from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear
+from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear
def get_mr_objects():
gamification/process/update.py
Outdated
@@ -10,6 +10,7 @@ | |||
from gamification.labels import NEGATIVE_POINT_LABELS | |||
from gamification.data.points import MERGE_REQUEST_CLOSED_WITHOUT_MERGE | |||
from gamification.models import Participant | |||
from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear |
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.
E261 at least two spaces before inline comment
Origin: PycodestyleBear (E261), Section: all.python.default
.
gamification/process/update.py
Outdated
@@ -10,6 +10,7 @@ | |||
from gamification.labels import NEGATIVE_POINT_LABELS | |||
from gamification.data.points import MERGE_REQUEST_CLOSED_WITHOUT_MERGE | |||
from gamification.models import Participant | |||
from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear |
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.
E501 line too long (84 > 80 characters)
Origin: PycodestyleBear (E501), Section: all.python.default
.
gamification/process/update.py
Outdated
|
||
|
||
def add_meta_review(participant): | ||
meta_participant = meta_participant.objects.values('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.
local variable 'meta_participant' (defined in enclosing scope on line 13) referenced before assignment
Origin: PyFlakesBear, Section: all.python.default
.
gamification/process/update.py
Outdated
@@ -10,6 +10,7 @@ | |||
from gamification.labels import NEGATIVE_POINT_LABELS | |||
from gamification.data.points import MERGE_REQUEST_CLOSED_WITHOUT_MERGE | |||
from gamification.models import Participant | |||
from meta_review.models import Participant as meta_participant # Ignore PyFlakesBear |
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.
Line is longer than allowed. (84 > 80)
Origin: LineLengthBear, Section: all.linelength
.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Netlify deploy is working on my end of another branch but not on this one. :( |
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.
See #181 (comment) and for:
Netlify deploy is working on my end of another branch but not on this one. :(
See #189
This comment has been minimized.
This comment has been minimized.
gamification/process/update.py
Outdated
@@ -56,7 +57,7 @@ def update_participants_data_with_mr(mr): | |||
|
|||
# Update participant data | |||
mr_author.add_points(mr_points, | |||
mr_activity_string, | |||
mr_activity_string, # Ignore PyFlakesBear |
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.
Any reason for this change?
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.
IDK why but on running coala
locally, I was receiving this traceback so I had no option but to add the ignore comment.
gamification/process/update.py
Outdated
@@ -135,6 +136,29 @@ def get_participant_objects(): | |||
return participants | |||
|
|||
|
|||
def update_participants_data_with_meta_review(participants): |
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.
On line 35 (https://github.com/coala/community/pull/190/files#diff-0bee1776ac8d509157f197b459b8b9afR35) you are calling update_participants_data_with_meta_review(participant)
but here it is called participants
. So should the argument be one participant or many participants?
gamification/process/update.py
Outdated
neg_in=participants.neg_in) | ||
neg_out_meta_review = meta_review_participants.objects.get( | ||
neg_out=participants.neg_out) | ||
if pos_in_meta_review > 0 or pos_out_meta_review > 0 or |
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.
gamification/process/update.py
Outdated
'Completed Meta-Review' activity. | ||
""" | ||
pos_in_meta_review = meta_review_participants.objects.get( | ||
pos_in=participants.pos_in) |
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 part makes me a bit confused. Does this ever work? Apparently participants
come from gamification.models
, which doesn't have pos_in
field.
meta_review_participants.objects.get(pos_in=some number)
doesn't make sense to me either. This returns an object whose pos_in
field = some number
.
.gitignore
Outdated
@@ -488,3 +488,5 @@ _site/ | |||
|
|||
# Pytest profile files | |||
prof/ | |||
*.orig | |||
.vscode/settings.json |
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.
Create a new issue for changes you want to make that are unrelated to this pr.
Also, .vscode
already exists in .gitignore
.
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.
Created #194
gamification/process/update.py
Outdated
@@ -135,6 +136,29 @@ def get_participant_objects(): | |||
return participants | |||
|
|||
|
|||
def update_participants_data_with_meta_review(participants): |
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.
One idea is that this method would take list of all the participants objects from the
meta-review partcipant model...and then iterate through each of the participant object from the list while filtering out only those participant whose usernames are in active_newcomer_list(as gamifiction system only work for those participant) and then if that participant have completed meta-review
then get the object of that participant from the gamification participant model and add the meta-review activity for that participant.
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.
What I am trying to do as of now:
-
Get a list of all the participants using
get_participant_objects()
-
Iterate over the above-mentioned list and send it to each participant to
update_participants_data_with_meta_review(participant)
-
Verify the conditions and store it as
True
orFalse
inparticipant.meta_review_completed
PS: I'm testing these changes on another branch so that while pushing the changes, my PR doesn't gets bad with Travis test failing messages
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 maybe you're getting confused b/w meta-review Participants
and gamification Participants
, meta-review system works for all members at coala and gamification system works for only active newcomers at coala.
participants from get_participant_objects()
are coming from gamification models, so they do not have fields like pos_in
and neg_out
etc..so you can't do1 as @li-boxuan mentioned there.
and where is meta_review_completed
field? if you want to do something like participant.meta_review_completed
with participant object you need a field of that name to the Participant
model. I think you don't need to do something like that, when you find that a participant has completed meta-review, just add the meta-review completed
activity for that participant by using add_activity
method.
Maybe rebase this commit on top of #152 so that this pr passes CI and we can see you changes running.
I'm testing these changes on another branch so that while pushing the changes, my PR doesn't gets bad with Travis test failing messages
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
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.
You need to figure out how to design update_participants_data_with_meta_review
. As mentioned #190 (comment) here, there are two concepts. One way to tackle this is that once you iterate through each meta-review participant, you need to check if they are a gamification participant. If yes, you need to somehow get corresponding gamification participant, and update its activity.
gamification/process/update.py
Outdated
neg_out=meta_review_participants.neg_out) | ||
if pos_in_meta_review > 0 or pos_out_meta_review > 0 or \ | ||
neg_in_meta_review > 0 or neg_out_meta_review > 0: | ||
participant.meta_review_completed = 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.
Is this field defined anywhere? Moreover, IMO this field should belong to gamification participant, not meta-review participant. Seems you are passing a meta-review participant to this function update_participants_data_with_meta_review
gamification/process/update.py
Outdated
'Completed Meta-Review' activity. | ||
""" | ||
pos_in_meta_review = meta_review_participants.objects.get( | ||
pos_in=meta_review_participants.pos_in) |
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 don't quite understand this. If you want to get the value of pos_in
of the current meta-review participant (seems the parameter of this function is meta_review participant), you should do pos_in_meta_review = participant.pos_in
I'm passing a meta-review participant from a list of participants extracted from
@li-boxuan @sks444 Your thoughts, please. Update: As far as I think, I have added everything as asked for except |
This comment has been minimized.
This comment has been minimized.
meta_review/models.py
Outdated
@@ -95,3 +95,12 @@ class Reaction(models.Model): | |||
giver = models.ForeignKey(Participant, related_name='give', null=True) | |||
receiver = models.ForeignKey(Participant, related_name='receive', null=True) | |||
review = models.ForeignKey(Comment, null=True) | |||
|
|||
def meta_review_add_activity(self): |
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.
meta-review activity shouldn't be defined in the meta-review app, but in the gamification app.
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.
Will change it. Apart from that is everything 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.
I think this is the major problem. Once the logic gets correct then we can focus on minor issues like coding style, etc.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gamification/process/update.py
Outdated
created_at = reaction_name.created_at | ||
updated_at = '2017-08-24 05:59:31+00:00' | ||
gamification_participant.add_activity( | ||
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.
horrible indentation. find a nicer way.
gamification/process/update.py
Outdated
username=meta_review_participant.login) | ||
reaction_name = Reaction.objects.get(id=meta_review_participant.login) | ||
if (meta_review_participant.pos_in > 0 or | ||
meta_review_participant.pos_out > 0 or |
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 violates pep8
gamification/process/update.py
Outdated
created_at = reaction_name.created_at | ||
updated_at = None | ||
gamification_participant.add_activity(0, activity, | ||
created_at, updated_at,) |
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.
a ,
before a )
is completely useless.
the concept is called trailing comma , because it adds a comma and the end of the line -- the absolute end of the line, with nothing after it.
but also, use hanging indent for these args, dont put the args on the same line as the function name. that isnt nice when the function name is long, as the args need to be squished on the RHS of the page.
gamification/process/update.py
Outdated
meta_review_participant.neg_out > 0): | ||
""" | ||
Add a meta-review activity to the participant | ||
""" |
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.
Use #
for comment here since it's single line anyway.
gamification/tests/test_models.py
Outdated
@@ -341,3 +349,48 @@ def test_add_badges_method(self): | |||
|
|||
# After applying add_badge method | |||
self.assertEquals(test_participant.badges.count(), 0) | |||
|
|||
def test_update_participants_data_with_meta_review(self): |
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.
Can you split this long test case to several smaller test cases?
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.
Can you please throw some light on how you want me to split it? It's because all of the 3 participants here are for the same stuff so it's becoming difficult to identify which form do I split it in. @li-boxuan
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.
Looking good. :)
gamification/process/update.py
Outdated
Update participants based on meta-review | ||
|
||
This method updates every participant based on the meta-review | ||
received or given. If the gamification participant is |
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.
gamification participant
--> meta-review participant
?
if meta_review_participant.login in active_newcomers_list:
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've done this already 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.
No, I meant the sentence should be If the meta-review participant is in..
?
gamification/process/update.py
Outdated
# Get the corresponding gamification participant | ||
gamification_participant = Participant.objects.get( | ||
username=meta_review_participant.login) | ||
reaction_name = Reaction.objects.get(id=meta_review_participant.login) |
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 confused here, how can Reaction id
would be equal to meta_review_participant login
?
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.
Reaction.id
and meta_review_participant.login
are the name of the participant. (I've cross checked it by printing both of them.)
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.
Really? How did you cross check that? That would be super weird.
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.
In test_model.py
, I printed both of them separately(with one testuser
) and for seeing the output, ran pytest -s
@li-boxuan
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 still don't believe it's correct. I might verify it myself later. If you want to accelerate the review process, add print after this line (print out the reaction instance you get and the meta_review_participant.login), run .ci/build.sh
, copy and past the result (one typical result is enough) here. Then I'll have to believe it and see if there is any other bug or voodoo.
Btw, reaction_name
is a weird name. It is a Reaction
instance, how come it being called 'reaction_name'?
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 cannot see anyone who has finished |
I'm myself able to understand why is it happening because the tests are running perfectly 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.
The netlify is not showing the result you want, because your code is wong.
Your tests are passing, because your tests are also wrong.
# meta-review participant | ||
meta_review_participant.objects.create(login='test2') | ||
test_meta_review_participant = meta_review_participant.objects.get( | ||
login='test2') |
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.
Unnecessary. meta_review_participant.objects.create(login='test2')
will return the instance.
test_meta_review_participant = meta_review_participant.objects.get( | ||
login='test2') | ||
|
||
Reaction.objects.create(id='test2') |
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, this is definitely inappropriate and prone to error. You are creating a reaction with id also equals to test2
, but the participant you created is also with id test2
.
# Get the corresponding gamification participant | ||
gamification_participant = Participant.objects.get( | ||
username=meta_review_participant.login) | ||
reaction = Reaction.objects.get(id=meta_review_participant.login) |
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 is definitely wrong. I checked the output you print out https://pastebin.com/6X6y5Kfx. You have the illusion that this works, because your test is wrong. In your test, both participant and reaction share the same id (primary_key), which gives you the wrong belief that you are correct.
That's why I said you should run .ci/build.sh
and show the log to prove this works. You can use that for debugging, but you don't need to prove anymore as I am pretty confident now this is wrong.
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.
@li-boxuan Thanks for your valuable input.
Can you please tell me what do I need to do in order to fix this? This thing is taking way much more time than I expected to. 😞
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.
First you need to fix the test case. See #190 (comment) so that your test won't pass (which is good coz now you know your code is wrong).
Then read the definition of Reaction
model. Understand the relationships between those models.
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.
In order to test things, I used my user handle shikharvaish28
. Ideally, I should be able to get reaction
using id
which is the primary key of Reaction
model.
test_meta_review_participant = meta_review_participant.objects.get(login='shikharvaish28')
reaction = Reaction.objects.get(id=test_meta_review_participant.login)
Instead, I am getting DoesNotExist: Reaction matching query does not exist.
Can you please tell me why is it so?
Since login
is the primary key of Participant
, I am expecting it to be linked in someway to id
of Reaction
. I want to do this because if I am somehow able to get the corresponding participant for Reaction
, everything would be sorted.
PS: I'm running these commands in django shell to get a gist of things.
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.
Since login is the primary key of Participant, I am expecting it to be linked in someway to id of Reaction.
Your assumption is wrong. Django does not work like that.
I strongly recommend you to read https://docs.djangoproject.com/en/2.1/topics/db/queries/, esepecially understand how Foreign Key works.
Add the meta-review activity on the gamification page for the active newcomers. Closes #181
Travis tests have failedHey @shikharvaish28, 1st Build./.ci/build.sh
TravisBuddy Request Identifier: d5919d10-e750-11e8-87c2-ebfa2f2e9d99 |
# Get the corresponding gamification participant | ||
gamification_participant = Participant.objects.get( | ||
username=meta_review_participant.login) | ||
reaction = Reaction.objects.get(id=meta_review_participant.login) |
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.
First you need to fix the test case. See #190 (comment) so that your test won't pass (which is good coz now you know your code is wrong).
Then read the definition of Reaction
model. Understand the relationships between those models.
@li-boxuan I'm closing this PR since I'm unable to solve this. I would prefer to do some other issues as of now. Kindly unassign me from this one so that this is free for someone else to take up. |
From this PR, we add the meta-review activity on the gamification page of the active newcomers.
Closes #181