added more pomidoro

This commit is contained in:
2026-06-09 11:54:32 +03:00
parent 244935e4ac
commit c8599b3d13
20 changed files with 817 additions and 91 deletions
+38
View File
@@ -0,0 +1,38 @@
import asyncio
import logging
from app.db.base import SessionLocal
from app.pomodoro.completion import PomodoroCompletionHandler
from app.pomodoro.service import PomodoroService
logger = logging.getLogger(__name__)
WATCH_INTERVAL_SEC = 2
async def pomodoro_watcher_loop() -> None:
while True:
try:
await asyncio.sleep(WATCH_INTERVAL_SEC)
await _tick()
except asyncio.CancelledError:
raise
except Exception:
logger.exception("Pomodoro watcher error")
async def _tick() -> None:
db = SessionLocal()
try:
service = PomodoroService(db)
service.get_status()
pending = service.get_pending_completions()
if not pending:
return
handler = PomodoroCompletionHandler(db)
for session in pending:
await handler.process(session)
finally:
db.close()