diff --git a/backend/app.py b/backend/app.py index d92c914..2f1be41 100644 --- a/backend/app.py +++ b/backend/app.py @@ -22,7 +22,7 @@ from watcher import configure_result_watcher, stop_result_watcher APP_ROOT = Path(__file__).resolve().parent -DB_PATH = APP_ROOT / "scheduler.db" +DB_PATH = Path(os.getenv("DB_PATH", str(APP_ROOT / "scheduler.db"))) DUT = os.getenv("DUT", "CGW453").strip() REF = os.getenv("REF", "CGW452").strip() @@ -473,14 +473,12 @@ def get_schedule_week(start: str | None = None, version: int | None = None) -> d raise HTTPException(status_code=404, detail=f"Schedule version {version} was not found") rows = db.get_schedule_week(week_start, selected_version, DB_PATH) - - # Log completed tests on the current schedule - completed_count = sum(1 for row in rows if row.status == 'completed') - if completed_count > 0: - print(f"[api] /schedule/week: {completed_count} test(s) marked as completed on calendar") - for row in rows: - if row.status == 'completed': - print(f" - {row.test_id} on {row.device} (scheduled {row.scheduled_date})") + + completed_rows = [row for row in rows if str(row.status).strip().lower() == "completed"] + rerun_rows = [row for row in rows if str(row.status).strip().lower() == "rerun"] + print( + f"[api] /schedule/week: completed={len(completed_rows)} rerun_required={len(rerun_rows)}" + ) all_rows = db.get_schedule_rows(selected_version, DB_PATH) completion_date = max((row.scheduled_date for row in all_rows), default=None) diff --git a/backend/db.py b/backend/db.py index 9b0a4a2..842a8a6 100644 --- a/backend/db.py +++ b/backend/db.py @@ -203,7 +203,10 @@ def upsert_tests(records: list[TestRecord], db_path: str | Path = DB_PATH) -> in victim_band = excluded.victim_band, throttled = excluded.throttled, estimated_minutes = excluded.estimated_minutes, - status = excluded.status, + status = CASE + WHEN tests.status IN ('completed', 'rerun') THEN tests.status + ELSE excluded.status + END, excluded = excluded.excluded, raw_payload = excluded.raw_payload, station_testpoint_map = excluded.station_testpoint_map, diff --git a/docker-compose.yml b/docker-compose.yml index 7f98330..cb50575 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,10 @@ services: environment: HOST_BROWSE_ROOT: ${HOST_BROWSE_ROOT} HOST_MOUNT_ROOT: /host + DB_PATH: /app/runtime/scheduler.db volumes: - ${HOST_BROWSE_ROOT}:/host - - scheduler-db:/app + - scheduler-db:/app/runtime expose: - "8000" restart: unless-stopped diff --git a/frontend/src/components/TestCard.jsx b/frontend/src/components/TestCard.jsx index 29727bf..42b913e 100644 --- a/frontend/src/components/TestCard.jsx +++ b/frontend/src/components/TestCard.jsx @@ -47,7 +47,8 @@ function formatConfig(config) { } export default function TestCard({ test }) { - const style = STATUS_STYLES[test.status] ?? STATUS_STYLES.pending + const normalizedStatus = String(test?.status ?? 'pending').trim().toLowerCase() + const style = STATUS_STYLES[normalizedStatus] ?? STATUS_STYLES.pending const deviceAccentClass = getDeviceAccentClass(test.device) const cardRef = useRef(null) const [tooltipPos, setTooltipPos] = useState({ top: '0px', left: '0px' })