fix: reset clears burn-in dashboard column via last_reset_at timestamp
Add last_reset_at column to drives table (migration-safe ALTER TABLE). _fetch_burnin_by_drive now excludes jobs created before the drive's last_reset_at, so the dashboard burn-in column goes blank after reset while the History page still shows the full job record. reset_drive stamps last_reset_at = now() alongside clearing smart_attrs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
645d55cfcc
commit
289c6d8f1a
2 changed files with 15 additions and 3 deletions
|
|
@ -87,6 +87,8 @@ _MIGRATIONS = [
|
|||
"ALTER TABLE burnin_stages ADD COLUMN bad_blocks INTEGER DEFAULT 0",
|
||||
"ALTER TABLE drives ADD COLUMN smart_attrs TEXT",
|
||||
"ALTER TABLE smart_tests ADD COLUMN raw_output TEXT",
|
||||
# Stage 8: track last reset time so dashboard burn-in col clears after reset
|
||||
"ALTER TABLE drives ADD COLUMN last_reset_at TEXT",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -118,11 +118,17 @@ _DRIVES_QUERY = """
|
|||
|
||||
|
||||
async def _fetch_burnin_by_drive(db: aiosqlite.Connection) -> dict[int, dict]:
|
||||
"""Return latest burn-in job (any state) keyed by drive_id."""
|
||||
"""Return latest burn-in job (any state) keyed by drive_id.
|
||||
|
||||
Jobs created before the drive's last_reset_at are excluded so the
|
||||
dashboard burn-in column clears after a reset while history is preserved.
|
||||
"""
|
||||
cur = await db.execute("""
|
||||
SELECT bj.*
|
||||
FROM burnin_jobs bj
|
||||
JOIN drives d ON d.id = bj.drive_id
|
||||
WHERE bj.id IN (SELECT MAX(id) FROM burnin_jobs GROUP BY drive_id)
|
||||
AND (d.last_reset_at IS NULL OR bj.created_at > d.last_reset_at)
|
||||
""")
|
||||
rows = await cur.fetchall()
|
||||
return {r["drive_id"]: dict(r) for r in rows}
|
||||
|
|
@ -733,8 +739,12 @@ async def reset_drive(
|
|||
WHERE drive_id=?""",
|
||||
(drive_id,),
|
||||
)
|
||||
# Clear cached SMART attributes
|
||||
await db.execute("UPDATE drives SET smart_attrs=NULL WHERE id=?", (drive_id,))
|
||||
# Clear SMART attrs cache + stamp reset time (hides prior burn-in from dashboard)
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
await db.execute(
|
||||
"UPDATE drives SET smart_attrs=NULL, last_reset_at=? WHERE id=?",
|
||||
(now, drive_id),
|
||||
)
|
||||
|
||||
# Audit event
|
||||
await db.execute(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue