|
|
|
@ -5,6 +5,7 @@ from django.utils import timezone |
|
|
|
from .enums import RegistrationStatus |
|
|
|
from .enums import RegistrationStatus |
|
|
|
from .player_enums import PlayerPaymentType |
|
|
|
from .player_enums import PlayerPaymentType |
|
|
|
from ..services.email_service import TournamentEmailService, TeamEmailType |
|
|
|
from ..services.email_service import TournamentEmailService, TeamEmailType |
|
|
|
|
|
|
|
from ..utils.extensions import format_seconds |
|
|
|
|
|
|
|
|
|
|
|
class TeamRegistration(SideStoreModel): |
|
|
|
class TeamRegistration(SideStoreModel): |
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) |
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) |
|
|
|
@ -205,6 +206,7 @@ class TeamRegistration(SideStoreModel): |
|
|
|
'initial_stage': self.get_initial_stage(), |
|
|
|
'initial_stage': self.get_initial_stage(), |
|
|
|
'matches_played': self.count_matches_played(), |
|
|
|
'matches_played': self.count_matches_played(), |
|
|
|
'victory_ratio': self.calculate_victory_ratio(), |
|
|
|
'victory_ratio': self.calculate_victory_ratio(), |
|
|
|
|
|
|
|
'time_played': self.calculate_time_played(), |
|
|
|
'team_rank': self.team_rank_label(), |
|
|
|
'team_rank': self.team_rank_label(), |
|
|
|
'total_teams': self.total_teams(), |
|
|
|
'total_teams': self.total_teams(), |
|
|
|
} |
|
|
|
} |
|
|
|
@ -287,6 +289,13 @@ class TeamRegistration(SideStoreModel): |
|
|
|
def count_matches_played(self): |
|
|
|
def count_matches_played(self): |
|
|
|
return self.get_matches().filter(end_date__isnull=False).count() |
|
|
|
return self.get_matches().filter(end_date__isnull=False).count() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_time_played(self): |
|
|
|
|
|
|
|
total_seconds = 0 |
|
|
|
|
|
|
|
for match in self.get_matches().filter(end_date__isnull=False): |
|
|
|
|
|
|
|
total_seconds += match.smart_time_played() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return format_seconds(total_seconds) |
|
|
|
|
|
|
|
|
|
|
|
def calculate_victory_ratio(self): |
|
|
|
def calculate_victory_ratio(self): |
|
|
|
matches = self.get_matches().filter(end_date__isnull=False) |
|
|
|
matches = self.get_matches().filter(end_date__isnull=False) |
|
|
|
total_matches = matches.count() |
|
|
|
total_matches = matches.count() |
|
|
|
|