feat(translation): live re-translate progress in the Settings card
translation/status now reports `active` (a translate/retranslate sweep is running, from the TaskRun table) and `last_run` (the most recent finished run's task + status). The Settings card polls live while a sweep runs, showing a spinner + "Translating… N remaining" that ticks down, and flags a last run that ended in error/timeout. No migration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,34 @@ async def test_translation_status_defaults(client):
|
||||
assert body["base_url_set"] is False
|
||||
assert body["healthy"] is False
|
||||
assert "untranslated_count" in body
|
||||
assert body["active"] is False # no sweep running
|
||||
assert body["last_run"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_translation_status_reports_active_and_last_run(client, db):
|
||||
# A running translate/retranslate TaskRun → active True; the most recent
|
||||
# finished one → last_run (task basename + status).
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from backend.app.models import TaskRun
|
||||
|
||||
db.add(TaskRun(
|
||||
celery_task_id="r-run", queue="maintenance_long",
|
||||
task_name="backend.app.tasks.translation.retranslate_posts",
|
||||
started_at=datetime.now(UTC), status="running",
|
||||
))
|
||||
db.add(TaskRun(
|
||||
celery_task_id="r-done", queue="maintenance_long",
|
||||
task_name="backend.app.tasks.translation.translate_posts",
|
||||
started_at=datetime.now(UTC), finished_at=datetime.now(UTC),
|
||||
status="success",
|
||||
))
|
||||
await db.commit()
|
||||
body = await (await client.get("/api/settings/translation/status")).get_json()
|
||||
assert body["active"] is True
|
||||
assert body["last_run"]["task"] == "translate_posts"
|
||||
assert body["last_run"]["status"] == "success"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user