-
Notifications
You must be signed in to change notification settings - Fork 31
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
Optimization PR#2
- Submissions and Participants Count
#1669
Conversation
… use these counts in the competition detail page, public competitions page, home page popular competitions
Very nice work. I'll review it asap. |
@ihsaan-ullah Any idea why your change triggers the following error? =================================== FAILURES ===================================
____________ SubmissionMixinTests.test_invalid_submission_not_sent _____________
self = <chahub.tests.test_chahub_mixin.SubmissionMixinTests testMethod=test_invalid_submission_not_sent>
def test_invalid_submission_not_sent(self):
self.submission.status = "Running"
self.submission.is_public = False
resp1 = self.mock_chahub_save(self.submission)
> assert not resp1.called
E AssertionError: assert not True
E + where True = <MagicMock name='_send' id='139945117507488'>.called
src/apps/chahub/tests/test_chahub_mixin.py:49: AssertionError
----------------------------- Captured stderr call -----------------------------
ChaHub :: Submission(224) is_valid = False
ChaHub :: Competition(161) is_valid = True
ChaHub :: Received response 201
Task chahub.tasks.send_to_chahub[2ffe7de6-212d-47c6-b4c1-fc6971c5ab19] succeeded in 0.004535872000019481s: None
------------------------------ Captured log call -------------------------------
INFO chahub.models:models.py:122 ChaHub :: Submission(224) is_valid = False
INFO chahub.models:models.py:122 ChaHub :: Competition(161) is_valid = True
INFO chahub.tasks:tasks.py:56 ChaHub :: Received response 201
INFO celery.app.trace:trace.py:125 Task chahub.tasks.send_to_chahub[2ffe7de6-212d-47c6-b4c1-fc6971c5ab19] succeeded in 0.004535872000019481s: None
____ SubmissionMixinTests.test_retrying_invalid_submission_wont_retry_again ____
self = <chahub.tests.test_chahub_mixin.SubmissionMixinTests testMethod=test_retrying_invalid_submission_wont_retry_again>
def test_retrying_invalid_submission_wont_retry_again(self):
self.submission.status = "Running"
self.submission.chahub_needs_retry = True
resp = self.mock_chahub_save(self.submission)
> assert not resp.called
E AssertionError: assert not True
E + where True = <MagicMock name='_send' id='139945080014256'>.called
src/apps/chahub/tests/test_chahub_mixin.py:59: AssertionError |
I checked the tests but could not figure out why they are failing. I will spend some more time on this soon |
@Didayolo I think these tests are useless because they are suppose to send submissions to ChaHub but there is no ChaHub right? |
PR#1
- Submissions and Participants CountPR#2
- Submissions and Participants Count
@ihsaan-ullah That is a good remark, however we may want to understand why these tests started to fail with this PR specifically. |
Maybe the problem is occurs because https://chahub.org/ does get the number of participants of the competitions? The renaming of |
The problem is in sending submissions to chahub but in the test there is a dummy chahub (no real URL is used) so that should not be a problem |
The tests are failing because of these lines of code added in the Submission modal's save function if is_new:
# Increment the submissions_count for the competition
self.phase.competition.submissions_count += 1
self.phase.competition.save() Removing this code fixes the problem. The real issue here is the test itself. If we don't have any chahub then why do we have tests for it and why do we have chahub fields in the submission? I think we should do the following:
|
Added tests for submisisons count and participants count |
OK for removing the test. Do you have a way to disable them, or do you want to simply erase them? |
For now I have commented the problematic tests. We can remove the tests permanently in a separate PR addressing #1683. I am going to prepare a script to update all the competitions and then we can merge this PR |
…r all competitions
Update counts for all competitionsBash into django console
Import and call the function from competitions.submission_participant_counts import compute_submissions_participants_counts
compute_submissions_participants_counts() |
@ mention of reviewers
@Didayolo
A brief description of the purpose of the changes contained in this PR.
This is a first PR in the optimization effort to load codabench quickly. The following are done in this PR:
participants_count
andsubmissions_count
participants_count
field in public competitions pageparticipants_count
field in the popular competitions section in home pageOn the backend, serializers are changed to use this new filed instead of the annotated values from the queries.
NOTE
submissions_count
will be updated (+1)submissions_count
will be updated (-1)participants_count
will update (+1)participants_count
is never decremented because we do not delete a participant we only revoke the statusManual update
1. Migration
docker compose exec django ./manage.py migrate
2. Update counts for all competitions
Bash into django console
Import and call the function
Issues this PR resolves
Submissions and Participants
Checklist