showing previous version schedule as faded
This commit is contained in:
+19
-1
@@ -406,6 +406,7 @@ def compile_schedule_endpoint(request: CompileScheduleRequest) -> dict[str, Any]
|
||||
top_priority_pairs: set[tuple[str, str]] = set()
|
||||
dut_top_priority_ids = {item.strip() for item in request.top_priority_tests_dut if item.strip()}
|
||||
ref_top_priority_ids = {item.strip() for item in request.top_priority_tests_ref if item.strip()}
|
||||
status_lookup = {(test.test_id, test.device): test.status for test in stored_tests}
|
||||
|
||||
# Backward compatibility: if only legacy top_priority_tests was sent,
|
||||
# keep previous behavior by applying IDs to whichever device has that test.
|
||||
@@ -445,7 +446,17 @@ def compile_schedule_endpoint(request: CompileScheduleRequest) -> dict[str, Any]
|
||||
raise HTTPException(status_code=409, detail=schedule_error)
|
||||
|
||||
version = db.create_schedule_version(
|
||||
[(e.test_id, e.device, e.scheduled_date, e.shift_index, e.sequence_in_shift) for e in entries],
|
||||
[
|
||||
(
|
||||
e.test_id,
|
||||
e.device,
|
||||
e.scheduled_date,
|
||||
e.shift_index,
|
||||
e.sequence_in_shift,
|
||||
status_lookup.get((e.test_id, e.device), "pending"),
|
||||
)
|
||||
for e in entries
|
||||
],
|
||||
DB_PATH,
|
||||
)
|
||||
print(f"Schedule version {version} created with {len(entries)} entries, completion date: {completion_date}")
|
||||
@@ -506,10 +517,17 @@ def get_schedule_week(start: str | None = None, version: int | None = None) -> d
|
||||
|
||||
all_rows = db.get_schedule_rows(selected_version, DB_PATH)
|
||||
completion_date = max((row.scheduled_date for row in all_rows), default=None)
|
||||
start_shift = min(
|
||||
((row.scheduled_date, row.shift_index) for row in all_rows),
|
||||
default=(None, None),
|
||||
)
|
||||
schedule_start_date, schedule_start_shift_index = start_shift
|
||||
holiday_dates = db.list_holidays(DB_PATH)
|
||||
return {
|
||||
"start_date": week_start,
|
||||
"schedule_version": selected_version,
|
||||
"schedule_start_date": schedule_start_date,
|
||||
"schedule_start_shift_index": schedule_start_shift_index,
|
||||
"items": [_serialize_schedule_row(row) for row in rows],
|
||||
"total_scheduled_tests": len(all_rows),
|
||||
"completion_date": completion_date,
|
||||
|
||||
Reference in New Issue
Block a user