|
@@ -0,0 +1,25 @@
|
|
|
|
|
+from datetime import timedelta
|
|
|
|
|
+from typing import TYPE_CHECKING
|
|
|
|
|
+
|
|
|
|
|
+from room_cal.actions.local_sync import local_sync
|
|
|
|
|
+from room_cal._periodic import register_periodic
|
|
|
|
|
+from room_cal._utils import local_today, get_config
|
|
|
|
|
+
|
|
|
|
|
+if TYPE_CHECKING:
|
|
|
|
|
+ from room_cal.service_api import ServiceAPI
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+async def _periodic_local_short(api: 'ServiceAPI') -> None:
|
|
|
|
|
+ start = local_today()
|
|
|
|
|
+ window = get_config().global_.reservation_window_days
|
|
|
|
|
+ await local_sync(start, start + timedelta(days=window))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+async def _periodic_local_long(api: 'ServiceAPI') -> None:
|
|
|
|
|
+ start = local_today()
|
|
|
|
|
+ window = get_config().global_.long_window_days
|
|
|
|
|
+ await local_sync(start, start + timedelta(days=window))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+register_periodic(_periodic_local_short, timedelta(hours=6))
|
|
|
|
|
+register_periodic(_periodic_local_long, timedelta(days=1))
|