diff --git a/Dockerfile b/Dockerfile index 79f7979..1b9e69d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app2/media WORKDIR /app2/static WORKDIR /app USER ctf -RUN python -m pip install --no-cache-dir --no-warn-script-location poetry +RUN python -m pip install --no-cache-dir --no-warn-script-location poetry COPY poetry.lock pyproject.toml /app/ RUN python -m poetry config virtualenvs.in-project true && \ @@ -27,7 +27,7 @@ USER ctf COPY . /app/ COPY ./mCTF/docker_config.py /app/mCTF/config.py USER root -RUN set -eux; cd /app/public/scss; mkdir out; for f in *.scss; \ +RUN set -eux; cd /app/public/scss; mkdir out; for f in *.scss; \ do \ sassc --style compressed -- "$f" "out/${f%.scss}.css"; \ done; \ @@ -41,5 +41,6 @@ EXPOSE 28730 CMD /app/.venv/bin/gunicorn \ --bind :28730 \ --error-logfile - \ + --timeout 120 \ --config /app/container/gunicorn.py \ mCTF.wsgi:application diff --git a/gameserver/models/contest.py b/gameserver/models/contest.py index 3e73f6d..8346754 100644 --- a/gameserver/models/contest.py +++ b/gameserver/models/contest.py @@ -260,12 +260,10 @@ def participant(self): def _get_unique_correct_submissions(self): # Switch to ContestProblem -> Problem Later - return ( - self.submissions.filter(submission__is_correct=True) - .values("submission__problem", "problem__points") - .distinct() - ) - + return (self.submissions.filter(submission__is_correct=True) + .select_related('problem') + .values('problem','problem__points').distinct()) + def points(self): points = self._get_unique_correct_submissions().aggregate( points=Coalesce(Sum("problem__points"), 0) @@ -382,6 +380,7 @@ class ContestSubmission(models.Model): on_delete=models.CASCADE, related_name="submissions", related_query_name="submission", + db_index=True, ) problem = models.ForeignKey( ContestProblem, @@ -390,7 +389,8 @@ class ContestSubmission(models.Model): related_query_name="submission", ) submission = models.OneToOneField( - "Submission", on_delete=models.CASCADE, related_name="contest_submission" + "Submission", on_delete=models.CASCADE, related_name="contest_submission", + db_index=True, ) def __str__(self):