add more types

This commit is contained in:
2024-08-08 21:19:43 +02:00
parent a5ac10b20d
commit 25deac6ea9
4 changed files with 66 additions and 53 deletions

View File

@ -2,7 +2,7 @@ from datetime import timedelta
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import F, Manager, Sum
from django.db.models import F, Sum
from django.utils import timezone
from common.time import format_duration
@ -15,6 +15,9 @@ class Game(models.Model):
wikidata = models.CharField(max_length=50, null=True, blank=True, default=None)
created_at = models.DateTimeField(auto_now_add=True)
session_average: float | int | timedelta | None
session_count: int | None
def __str__(self):
return self.name
@ -220,7 +223,7 @@ class Session(models.Model):
def duration_sum(self) -> str:
return Session.objects.all().total_duration_formatted()
def save(self, *args, **kwargs):
def save(self, *args, **kwargs) -> None:
if self.timestamp_start != None and self.timestamp_end != None:
self.duration_calculated = self.timestamp_end - self.timestamp_start
else: