Coverage for src/kwai/modules/training/trainings/training_query.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines an interface for a training query."""
3from abc import ABC, abstractmethod
5from kwai.core.domain.repository.query import Query
6from kwai.core.domain.value_objects.timestamp import Timestamp
7from kwai.modules.training.coaches.coach import CoachEntity
8from kwai.modules.training.teams.team import TeamEntity
9from kwai.modules.training.trainings.training import TrainingIdentifier
10from kwai.modules.training.trainings.training_definition import TrainingDefinitionEntity
13class TrainingQuery(Query, ABC):
14 """Interface for a training query."""
16 @abstractmethod
17 def filter_by_id(self, id_: TrainingIdentifier) -> "TrainingQuery":
18 """Add a filter on a training identifier.
20 Args:
21 id_: id of a training.
22 """
23 raise NotImplementedError
25 @abstractmethod
26 def filter_by_year_month(
27 self, year: int, month: int | None = None
28 ) -> "TrainingQuery":
29 """Add filter to get only trainings for the given year/month.
31 Args:
32 year: The year to use for the filter.
33 month: The month to use for the filter.
34 """
35 raise NotImplementedError
37 @abstractmethod
38 def filter_by_dates(self, start: Timestamp, end: Timestamp) -> "TrainingQuery":
39 """Add filter to get only trainings between two dates.
41 Args:
42 start: The start date to use for the filter.
43 end: The end date to use for the filter.
44 """
45 raise NotImplementedError
47 @abstractmethod
48 def filter_by_coach(self, coach: CoachEntity) -> "TrainingQuery":
49 """Add filter to get only trainings for the given week.
51 Args:
52 coach: The coach to use for the filter.
53 """
54 raise NotImplementedError
56 @abstractmethod
57 def filter_by_team(self, team: TeamEntity) -> "TrainingQuery":
58 """Add filter to get only trainings for the given team.
60 Args:
61 team: The team to use for the filter.
62 """
63 raise NotImplementedError
65 @abstractmethod
66 def filter_by_definition(
67 self, definition: TrainingDefinitionEntity
68 ) -> "TrainingQuery":
69 """Add filter to get only trainings for the given definition.
71 Args:
72 definition: The definition to use for the filter.
73 """
74 raise NotImplementedError
76 @abstractmethod
77 def filter_active(self) -> "TrainingQuery":
78 """Add filter to get only the active trainings."""
79 raise NotImplementedError
81 @abstractmethod
82 def order_by_date(self) -> "TrainingQuery":
83 """Order the trainings by date."""
84 raise NotImplementedError