Coverage for kwai/modules/training/trainings/training_query.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Module that defines an interface for a training query."""
2from abc import ABC, abstractmethod
3from datetime import datetime
5from kwai.core.domain.repository.query import Query
6from kwai.modules.training.coaches.coach import CoachEntity
7from kwai.modules.training.teams.team import TeamEntity
8from kwai.modules.training.trainings.training import TrainingIdentifier
9from kwai.modules.training.trainings.training_definition import TrainingDefinitionEntity
12class TrainingQuery(Query, ABC):
13 """Interface for a training query."""
15 @abstractmethod
16 def filter_by_id(self, id_: TrainingIdentifier) -> "TrainingQuery":
17 """Add a filter on a training identifier.
19 Args:
20 id_: id of a training.
21 """
22 raise NotImplementedError
24 @abstractmethod
25 def filter_by_year_month(
26 self, year: int, month: int | None = None
27 ) -> "TrainingQuery":
28 """Add filter to get only trainings for the given year/month.
30 Args:
31 year: The year to use for the filter.
32 month: The month to use for the filter.
33 """
34 raise NotImplementedError
36 @abstractmethod
37 def filter_by_dates(self, start: datetime, end: datetime) -> "TrainingQuery":
38 """Add filter to get only trainings between two dates.
40 Args:
41 start: The start date to use for the filter.
42 end: The end date to use for the filter.
43 """
44 raise NotImplementedError
46 @abstractmethod
47 def filter_by_coach(self, coach: CoachEntity) -> "TrainingQuery":
48 """Add filter to get only trainings for the given week.
50 Args:
51 coach: The coach to use for the filter.
52 """
53 raise NotImplementedError
55 @abstractmethod
56 def filter_by_team(self, team: TeamEntity) -> "TrainingQuery":
57 """Add filter to get only trainings for the given team.
59 Args:
60 team: The team to use for the filter.
61 """
62 raise NotImplementedError
64 @abstractmethod
65 def filter_by_definition(
66 self, definition: TrainingDefinitionEntity
67 ) -> "TrainingQuery":
68 """Add filter to get only trainings for the given definition.
70 Args:
71 definition: The definition to use for the filter.
72 """
73 raise NotImplementedError
75 @abstractmethod
76 def filter_active(self) -> "TrainingQuery":
77 """Add filter to get only the active trainings."""
78 raise NotImplementedError
80 @abstractmethod
81 def order_by_date(self) -> "TrainingQuery":
82 """Order the trainings by date."""
83 raise NotImplementedError