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

Further scorelog cleanup #1

Open
wants to merge 1 commit into
base: cleanup_scorelog
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions pootle/apps/pootle_statistics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ def save(self, *args, **kwargs):

scorelogs_created = []
for score in ScoreLog.get_scorelogs(submission=self):
if 'action_code' in score and score['user'] is not None:
if not isinstance(score["user"], models.Model):
score["user_id"] = score["user"]
del score["user"]
if 'action_code' in score and score['user_id'] is not None:
Copy link
Owner

Choose a reason for hiding this comment

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

@ta2-1 in my testing sometimes the user was a real user object - in these cases it saves sql to pass it through

scorelogs_created.append(ScoreLog(**score))
if scorelogs_created:
self.scorelog_set.add(*scorelogs_created)
Expand Down Expand Up @@ -425,14 +422,14 @@ def get_scorelogs(cls, submission):
reviewer = translator

previous_translator_score = score_dict.copy()
previous_translator_score['user'] = translator
previous_translator_score['user_id'] = translator
previous_reviewer_score = score_dict.copy()
previous_reviewer_score['user'] = reviewer
previous_reviewer_score['user_id'] = reviewer
submitter_score = score_dict.copy()
submitter_score['user'] = submission.submitter
submitter_score['user_id'] = submission.submitter_id
suggester_score = score_dict.copy()
if submission.suggestion is not None:
suggester_score['user'] = submission.suggestion.user
suggester_score['user_id'] = submission.suggestion.user_id

if (submission.field == SubmissionFields.TARGET and
submission.type in SubmissionTypes.EDIT_TYPES):
Expand Down Expand Up @@ -505,7 +502,7 @@ def save(self, *args, **kwargs):
super(ScoreLog, self).save(*args, **kwargs)

User = get_user_model()
User.objects.filter(id=self.user.id).update(
User.objects.filter(id=self.user_id).update(
score=F('score') + self.score_delta
)
self.log()
Expand Down