speling is difikult

This commit is contained in:
Frank Schwenk
2026-06-10 10:03:35 +02:00
parent fef0454895
commit b71eec94f8
4 changed files with 108 additions and 13 deletions
+37 -11
View File
@@ -72,7 +72,11 @@ async def _call_openrouter(prompt: str, *, system: str) -> str | None:
def _motivation_key(day: str) -> str:
return f"motivation:{day}"
return f"motivation:v2:{day}"
def _oracle_key(week: str) -> str:
return f"oracle:v2:{week}"
async def _cached_motivation(db: aiosqlite.Connection, day: str) -> str | None:
@@ -86,12 +90,15 @@ async def generate_daily_motivation(
db: aiosqlite.Connection,
tz: ZoneInfo,
day: str | None = None,
*,
force: bool = False,
) -> dict[str, Any]:
day = day or datetime.now(tz).strftime("%Y-%m-%d")
key = _motivation_key(day)
cached = await _cached_motivation(db, day)
if cached:
return {"text": cached, "source": "cache", "day": day}
if not force:
cached = await _cached_motivation(db, day)
if cached:
return {"text": cached, "source": "cache", "day": day}
stats = await compute_stats(db)
prompt = (
@@ -123,12 +130,19 @@ async def get_roast_of_the_day(db: aiosqlite.Connection, tz: ZoneInfo) -> dict[s
return await get_daily_motivation(db, tz)
async def get_oracle(db: aiosqlite.Connection, tz: ZoneInfo) -> dict[str, Any]:
week = datetime.now(tz).strftime("%Y-W%W")
key = f"oracle:{week}"
cached = await _get_cache(db, key)
if cached:
return {"text": cached, "source": "cache", "week": week}
async def generate_oracle(
db: aiosqlite.Connection,
tz: ZoneInfo,
week: str | None = None,
*,
force: bool = False,
) -> dict[str, Any]:
week = week or datetime.now(tz).strftime("%Y-W%W")
key = _oracle_key(week)
if not force:
cached = await _get_cache(db, key)
if cached:
return {"text": cached, "source": "cache", "week": week}
stats = await compute_stats(db)
days_active = stats["days_active"]
@@ -165,5 +179,17 @@ async def get_oracle(db: aiosqlite.Connection, tz: ZoneInfo) -> dict[str, Any]:
else:
source = "ai"
await _set_cache(db, key, text)
logger.info("Generated oracle for %s (%s)", week, source)
return {"text": text, "source": source, "week": week}
async def get_oracle(db: aiosqlite.Connection, tz: ZoneInfo) -> dict[str, Any]:
week = datetime.now(tz).strftime("%Y-W%W")
cached = await _get_cache(db, _oracle_key(week))
if cached:
return {"text": cached, "source": "cache", "week": week}
return {
"text": "Das Orakel bereitet sich vor. Schau später nochmal rein.",
"source": "pending",
"week": week,
}