Coverage for bc/kwai-bc-training/src/kwai_bc_training/trainings/training_query.py: 100%
8 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, 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
8from kwai_bc_training.coaches.coach import CoachEntity
9from kwai_bc_training.teams.team import TeamEntity
10from kwai_bc_training.trainings.training import TrainingIdentifier
11from kwai_bc_training.trainings.training_schedule import TrainingScheduleEntity
14class TrainingQuery(Query, ABC):
15 """Interface for a training query."""
17 @abstractmethod
18 def filter_by_id(self, id_: TrainingIdentifier) -> "TrainingQuery":
19 """Add a filter on a training identifier.
21 Args:
22 id_: id of a training.
23 """
24 raise NotImplementedError
26 @abstractmethod
27 def filter_by_year_month(
28 self, year: int, month: int | None = None
29 ) -> "TrainingQuery":
30 """Add filter to get only trainings for the given year/month.
32 Args:
33 year: The year to use for the filter.
34 month: The month to use for the filter.
35 """
36 raise NotImplementedError
38 @abstractmethod
39 def filter_by_dates(self, start: Timestamp, end: Timestamp) -> "TrainingQuery":
40 """Add filter to get only trainings between two dates.
42 Args:
43 start: The start date to use for the filter.
44 end: The end date to use for the filter.
45 """
46 raise NotImplementedError
48 @abstractmethod
49 def filter_by_coach(self, coach: CoachEntity) -> "TrainingQuery":
50 """Add filter to get only trainings for the given week.
52 Args:
53 coach: The coach to use for the filter.
54 """
55 raise NotImplementedError
57 @abstractmethod
58 def filter_by_team(self, team: TeamEntity) -> "TrainingQuery":
59 """Add filter to get only trainings for the given team.
61 Args:
62 team: The team to use for the filter.
63 """
64 raise NotImplementedError
66 @abstractmethod
67 def filter_by_training_schedule(
68 self, training_schedule: TrainingScheduleEntity
69 ) -> "TrainingQuery":
70 """Add filter to get only trainings for the given training schedule.
72 Args:
73 training_schedule: The training schedule to use for the filter.
74 """
75 raise NotImplementedError
77 @abstractmethod
78 def filter_active(self) -> "TrainingQuery":
79 """Add filter to get only the active trainings."""
80 raise NotImplementedError
82 @abstractmethod
83 def order_by_date(self) -> "TrainingQuery":
84 """Order the trainings by date."""
85 raise NotImplementedError