initial
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
import asyncio
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
from api import api
|
||||
from database import get_active_groups
|
||||
|
||||
|
||||
async def refresh_cache():
|
||||
|
||||
while True:
|
||||
|
||||
groups = await get_active_groups()
|
||||
|
||||
if groups:
|
||||
|
||||
print(f"[CACHE] Обновляем {len(groups)} групп")
|
||||
|
||||
for group_id in groups:
|
||||
|
||||
try:
|
||||
|
||||
# сегодня
|
||||
await api.get_schedule(
|
||||
group_id,
|
||||
date.today()
|
||||
)
|
||||
|
||||
# завтра
|
||||
await api.get_schedule(
|
||||
group_id,
|
||||
date.today() + timedelta(days=1)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(
|
||||
f"[CACHE] Ошибка {group_id}: {e}"
|
||||
)
|
||||
|
||||
await asyncio.sleep(1800)
|
||||
Reference in New Issue
Block a user