Add a weekly cadence to the match schedule #15

Merged
mdiluz merged 7 commits from issue-9-advanced-cadence into main 2024-09-22 14:26:39 +01:00
Showing only changes of commit d83f933f1d - Show all commits

View file

@ -340,7 +340,10 @@ class _State():
for channel, tasks in self._tasks.items(): for channel, tasks in self._tasks.items():
for match in tasks.get(_Key.MATCH_TASKS, []): for match in tasks.get(_Key.MATCH_TASKS, []):
if match[_Key.WEEKDAY] == weekday and match[_Key.HOUR] == hour: # Take into account the weekly cadence
start = ts_to_datetime(match[_Key.CADENCE_START])
weeks = int((time - start).days / 7)
if match[_Key.WEEKDAY] == weekday and match[_Key.HOUR] == hour and weeks % match[_Key.CADENCE] == 0:
yield (channel, match[_Key.MEMBERS_MIN]) yield (channel, match[_Key.MEMBERS_MIN])
def get_channel_match_tasks(self, channel_id: str) -> Generator[int, int, int]: def get_channel_match_tasks(self, channel_id: str) -> Generator[int, int, int]: