Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

closes #53

  • Loading branch information...
commit aae2e7163b19501ecf8ba77c290e5faf5525cf76 1 parent 8d27179
@nomadali authored
Showing with 18 additions and 3 deletions.
  1. +16 −1 src/jeeqs.py
  2. +2 −2 src/models.py
View
17 src/jeeqs.py
@@ -455,12 +455,22 @@ def update_submission(submission, jeeqser_challenge, vote, voter):
spam_manager.flag_author(submission.author)
submission.flagged_by.append(voter.key())
+ previous_status = submission.status
+
#update status on submission and jeeqser_challenge
if submission.correct_count > submission.incorrect_count + submission.flag_count:
submission.status = jeeqser_challenge.status = 'correct'
else:
submission.status = jeeqser_challenge.status = 'incorrect'
+ # TODO: This may not scale since challenge's entity group is high traffic - use sharded counters
+ if submission.status != previous_status:
+ if submission.status == 'correct':
+ submission.challenge.num_jeeqsers_solved += 1
+ elif submission.status == 'incorrect' and None != previous_status:
+ submission.challenge.num_jeeqsers_solved -= 1
+
+
def get_in_jeeqs(self):
submission_key = self.request.get('submission_key')
@@ -581,7 +591,7 @@ def submit_solution(self):
new_solution += ' ' + line
solution = new_solution
- # We can convert two foreign keys into a single key and move this inside the transaction
+ # TODO: We can convert two foreign keys (jeeqser, challenge) into a single key and get the key faster
jeeqser_challenge = Jeeqser_Challenge\
.all()\
.filter('jeeqser = ', self.jeeqser)\
@@ -611,6 +621,9 @@ def persist_new_submission():
challenge = challenge
)
+ challenge.num_jeeqsers_submitted += 1
+ challenge.put()
+
attempt = Attempt(
author=self.jeeqser.key(),
challenge=challenge,
@@ -652,6 +665,7 @@ def persist_testcase_results():
feedback.put()
jeeqser_challenge.put()
attempt.put()
+ attempt.challenge.put()
# attempt.author doesn't need to be persisted, since it will only change when an attempt is flagged.
xg_on = db.create_transaction_options(xg=True)
@@ -759,6 +773,7 @@ def persist_vote():
jeeqser_challenge.put()
submission.put()
+ submission.challenge.put()
jeeqser.put()
submission.author.put()
feedback.put()
View
4 src/models.py
@@ -137,8 +137,8 @@ def set_name(self, value):
vertical_scroll = db.FloatProperty()
#stats
- num_jeeqsers_solved = db.IntegerProperty()
- num_jeeqsers_submitted = db.IntegerProperty()
+ num_jeeqsers_solved = db.IntegerProperty(default=0)
+ num_jeeqsers_submitted = db.IntegerProperty(default=0)
def get_breadcrumb(self):
if self.breadcrumb_persisted:
Please sign in to comment.
Something went wrong with that request. Please try again.