Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mcpt/ctf
Browse files Browse the repository at this point in the history
  • Loading branch information
HillcrestEnigma committed Mar 9, 2024
2 parents 5e43f34 + ef17b1d commit c3e91f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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; \
Expand All @@ -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
14 changes: 7 additions & 7 deletions gameserver/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit c3e91f6

Please sign in to comment.