Add cadence values to the matchy tasks
cadence - Run this task every "x" weeks cadence - Unix seconds timestamp for the start of this cadence
This commit is contained in:
parent
caadca885c
commit
b86aaf7016
1 changed files with 17 additions and 1 deletions
|
@ -16,7 +16,7 @@ logger = logging.getLogger("state")
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
# Warning: Changing any of the below needs proper thought to ensure backwards compatibility
|
# Warning: Changing any of the below needs proper thought to ensure backwards compatibility
|
||||||
_VERSION = 4
|
_VERSION = 5
|
||||||
|
|
||||||
|
|
||||||
def _migrate_to_v1(d: dict):
|
def _migrate_to_v1(d: dict):
|
||||||
|
@ -64,12 +64,24 @@ def _migrate_to_v4(d: dict):
|
||||||
del d[_Key._HISTORY]
|
del d[_Key._HISTORY]
|
||||||
|
|
||||||
|
|
||||||
|
def _migrate_to_v5(d: dict):
|
||||||
|
"""v5 added weekly cadence"""
|
||||||
|
tasks = d.get(_Key.TASKS, {})
|
||||||
|
for tasks in tasks.values():
|
||||||
|
match_tasks = tasks.get(_Key.MATCH_TASKS, [])
|
||||||
|
for match in match_tasks:
|
||||||
|
# All previous matches were every week starting from now
|
||||||
|
match[_Key.CADENCE] = 1
|
||||||
|
match[_Key.CADENCE_START] = int(datetime.now().timestamp())
|
||||||
|
|
||||||
|
|
||||||
# Set of migration functions to apply
|
# Set of migration functions to apply
|
||||||
_MIGRATIONS = [
|
_MIGRATIONS = [
|
||||||
_migrate_to_v1,
|
_migrate_to_v1,
|
||||||
_migrate_to_v2,
|
_migrate_to_v2,
|
||||||
_migrate_to_v3,
|
_migrate_to_v3,
|
||||||
_migrate_to_v4,
|
_migrate_to_v4,
|
||||||
|
_migrate_to_v5
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +106,8 @@ class _Key(str):
|
||||||
MEMBERS_MIN = "members_min"
|
MEMBERS_MIN = "members_min"
|
||||||
WEEKDAY = "weekdays"
|
WEEKDAY = "weekdays"
|
||||||
HOUR = "hours"
|
HOUR = "hours"
|
||||||
|
CADENCE = "cadence"
|
||||||
|
CADENCE_START = "CADENCE_START"
|
||||||
|
|
||||||
# Unused
|
# Unused
|
||||||
_MATCHEES = "matchees"
|
_MATCHEES = "matchees"
|
||||||
|
@ -139,6 +153,8 @@ _SCHEMA = Schema(
|
||||||
_Key.MEMBERS_MIN: Use(int),
|
_Key.MEMBERS_MIN: Use(int),
|
||||||
_Key.WEEKDAY: Use(int),
|
_Key.WEEKDAY: Use(int),
|
||||||
_Key.HOUR: Use(int),
|
_Key.HOUR: Use(int),
|
||||||
|
_Key.CADENCE: Use(int),
|
||||||
|
_Key.CADENCE_START: Use(int),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue