This commit is contained in:
Raykov-MS 2026-02-28 21:15:45 +03:00
parent e07a922f23
commit 6e8c3b8d6a

11
main.py
View File

@ -7,7 +7,7 @@ import random
import sqlite3
from contextlib import asynccontextmanager
from dataclasses import dataclass
from datetime import date, datetime, timezone
from datetime import date, datetime, timedelta, timezone
from typing import Any
import httpx
@ -42,6 +42,7 @@ GITEA_COUNT_REPOS = {
for v in os.getenv("GITEA_COUNT_REPOS", "").split(",")
if v.strip()
}
MSK_TZ = timezone(timedelta(hours=3))
@dataclass
@ -56,6 +57,10 @@ def utc_now() -> datetime:
return datetime.now(timezone.utc)
def msk_now() -> datetime:
return datetime.now(MSK_TZ)
def parse_date(value: str) -> date:
return datetime.strptime(value, "%Y-%m-%d").date()
@ -728,7 +733,7 @@ async def handle_pr_opened(payload: dict[str, Any]) -> None:
candidates = storage.get_available_candidates(
author_login=author_login,
today=utc_now().date(),
today=msk_now().date(),
allow_self_assign=ALLOW_SELF_ASSIGN,
)
if not candidates:
@ -878,7 +883,7 @@ async def handle_pr_reviewed(payload: dict[str, Any]) -> None:
async def reminder_loop() -> None:
while True:
try:
now = utc_now()
now = msk_now()
hh_mm = now.strftime("%H:%M")
day_key = now.date().isoformat()
users = storage.get_all_users()