feat: improve generation analytics and maintenance

This commit is contained in:
2026-04-19 09:03:40 +08:00
parent d5a173aa0d
commit 5318de670f
21 changed files with 1155 additions and 57 deletions

View File

@@ -49,6 +49,14 @@ celery_app.conf.update(
"task": "app.tasks.memory.prune_memories_task",
"schedule": crontab(minute="0", hour="3"), # Daily at 03:00
},
"prune_story_audio_cache": {
"task": "app.tasks.audio_cache.prune_story_audio_cache_task",
"schedule": crontab(minute="30", hour="3"), # Daily at 03:30
},
"prune_stale_generation_jobs": {
"task": "app.tasks.generation_maintenance.prune_stale_generation_jobs_task",
"schedule": crontab(minute="*/30"),
},
},
)

View File

@@ -62,12 +62,20 @@ class Settings(BaseSettings):
False,
description="Enable local deterministic demo providers for portfolio demos",
)
story_audio_cache_dir: str = Field(
"storage/audio",
description="Directory for cached story audio files",
)
# Celery (Redis)
story_audio_cache_dir: str = Field(
"storage/audio",
description="Directory for cached story audio files",
)
story_audio_cache_ttl_days: int = Field(
30,
description="TTL in days before cached story audio is pruned",
)
generation_job_stale_minutes: int = Field(
60,
description="Minutes before a running generation job is considered stale",
)
# Celery (Redis)
celery_broker_url: str = Field("redis://localhost:6379/0")
celery_result_backend: str = Field("redis://localhost:6379/0")