refactor: extract admin business logic to services, introduce job queue, add derived index helpers

- Move DB operations from routes/admin.py to services/admin.py (get_logs_context, query_summary_statuses, retry_failed, delete/reset operations)
- Add services/jobs.py with Job/JobEvent-based async job queue (create_job, run_job, enqueue_job)
- Add services/derived.py with FTS5 reindex and paper index deletion helpers
- Refactor scheduler to use job queue instead of direct pipeline calls
- Add heartbeat_at/expires_at to TaskLock for lock health tracking
- Remove DESIGN_REVIEW.md
- Update tests: remove redundant integration tests, add unit tests for new services
This commit is contained in:
2026-06-13 18:31:43 +08:00
parent 21f16e6756
commit 743d69efd0
20 changed files with 1391 additions and 1063 deletions
+7
View File
@@ -32,7 +32,14 @@ async def lifespan(app: FastAPI):
# ── startup ──
from app.services.scheduler import start_scheduler
from app.services.embedder import init_chroma
from app.services.jobs import recover_stale_jobs
from app.database import SessionLocal
db = SessionLocal()
try:
recover_stale_jobs(db)
finally:
db.close()
start_scheduler()
init_chroma()