Skip to content

Commit

Permalink
Fixed some type issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Mar 11, 2024
1 parent b15bcf1 commit 87bee98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gameserver/models/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class UserScore(models.Model):
user = models.ForeignKey("User", on_delete=models.CASCADE, db_index=True, unique=True)
user = models.OneToOneField("User", on_delete=models.CASCADE, db_index=True)
points = models.PositiveIntegerField(help_text="The amount of points.", default=0)
flag_count = models.PositiveIntegerField(help_text="The amount of flags the user/team has.", default=0)

Expand Down Expand Up @@ -41,7 +41,7 @@ def invalidate(cls, user: "User"):


@classmethod
def get(cls, user: "User") -> "Self" | None:
def get(cls, user: "User") -> Self | None:
obj = cls.objects.filter(user=user)
if obj is None:
return None
Expand Down Expand Up @@ -71,7 +71,7 @@ def initalize_data(cls):
cls.objects.bulk_create(scores_to_create)

class ContestScore(models.Model):
participation=models.ForeignKey("ContestParticipation", on_delete=models.CASCADE, db_index=True, unique=True)
participation = models.OneToOneField("ContestParticipation", on_delete=models.CASCADE, db_index=True)
points = models.PositiveIntegerField(help_text="The amount of points.", default=0)
flag_count = models.PositiveIntegerField(help_text="The amount of flags the user/team has.", default=0)

Expand All @@ -97,15 +97,15 @@ def update_or_create(cls, change_in_score: int, participant: "ContestParticipati
queryset.update(points=F('points') + change_in_score, flag_count=F('flag_count') + 1)

@classmethod
def invalidate(cls, participant: ContestParticipation):
def invalidate(cls, participant: "ContestParticipation"):
try:
cls.objects.get(participant=participant).delete()
except cls.DoesNotExist:
pass # participant was not found.


@classmethod
def get(cls, participant: ContestParticipation) -> None | "ContestScore":
def get(cls, participant: "ContestParticipation") -> Self | None:
obj = cls.objects.filter(participant=participant)
if obj is None:
return None
Expand Down

0 comments on commit 87bee98

Please sign in to comment.