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

1"""Module that defines an interface for a training query.""" 

2 

3from abc import ABC, abstractmethod 

4 

5from kwai_core.domain.repository.query import Query 

6from kwai_core.domain.value_objects.timestamp import Timestamp 

7 

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 

12 

13 

14class TrainingQuery(Query, ABC): 

15 """Interface for a training query.""" 

16 

17 @abstractmethod 

18 def filter_by_id(self, id_: TrainingIdentifier) -> "TrainingQuery": 

19 """Add a filter on a training identifier. 

20 

21 Args: 

22 id_: id of a training. 

23 """ 

24 raise NotImplementedError 

25 

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. 

31 

32 Args: 

33 year: The year to use for the filter. 

34 month: The month to use for the filter. 

35 """ 

36 raise NotImplementedError 

37 

38 @abstractmethod 

39 def filter_by_dates(self, start: Timestamp, end: Timestamp) -> "TrainingQuery": 

40 """Add filter to get only trainings between two dates. 

41 

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 

47 

48 @abstractmethod 

49 def filter_by_coach(self, coach: CoachEntity) -> "TrainingQuery": 

50 """Add filter to get only trainings for the given week. 

51 

52 Args: 

53 coach: The coach to use for the filter. 

54 """ 

55 raise NotImplementedError 

56 

57 @abstractmethod 

58 def filter_by_team(self, team: TeamEntity) -> "TrainingQuery": 

59 """Add filter to get only trainings for the given team. 

60 

61 Args: 

62 team: The team to use for the filter. 

63 """ 

64 raise NotImplementedError 

65 

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. 

71 

72 Args: 

73 training_schedule: The training schedule to use for the filter. 

74 """ 

75 raise NotImplementedError 

76 

77 @abstractmethod 

78 def filter_active(self) -> "TrainingQuery": 

79 """Add filter to get only the active trainings.""" 

80 raise NotImplementedError 

81 

82 @abstractmethod 

83 def order_by_date(self) -> "TrainingQuery": 

84 """Order the trainings by date.""" 

85 raise NotImplementedError