Skip to content

Commit

Permalink
Added some additional db indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Apr 6, 2024
1 parent 672837e commit 9937701
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 2 additions & 6 deletions gameserver/models/contest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from datetime import timedelta

from django.apps import apps
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key
from django.core.validators import MinValueValidator
from django.db import models
from django.db.models import Count, F, Max, Min, OuterRef, Q, Subquery, Sum
from django.db.models.expressions import Window
from django.db.models.functions import Coalesce, Rank
from django.db.models import Min, Q
from django.urls import reverse
from django.utils import timezone
from django.utils.functional import cached_property
Expand Down Expand Up @@ -49,7 +45,7 @@ def __init__(self, *args, **kwargs):

tags = models.ManyToManyField(ContestTag, blank=True)

is_public = models.BooleanField(default=True)
is_public = models.BooleanField(default=True, db_index=True)
max_team_size = models.PositiveSmallIntegerField(
null=True, blank=True, validators=[MinValueValidator(1)]
)
Expand Down
2 changes: 1 addition & 1 deletion gameserver/models/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Problem(models.Model):
challenge_spec = models.JSONField(null=True, blank=True)
log_submission_content = models.BooleanField(default=False)

is_public = models.BooleanField(default=False)
is_public = models.BooleanField(default=False, db_index=True)

date_created = models.DateTimeField(auto_now_add=True)

Expand Down
2 changes: 2 additions & 0 deletions gameserver/models/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class Submission(models.Model):
blank=True,
related_name="submissions",
related_query_name="submission",
db_index=True,
)
problem = models.ForeignKey(
"Problem",
on_delete=models.CASCADE,
related_name="submissions",
db_index=True,
related_query_name="submission",
)
is_correct = models.BooleanField(default=False, db_index=True)
Expand Down

0 comments on commit 9937701

Please sign in to comment.