diff --git a/containers/backupchecks/src/backend/app/main/routes_run_checks.py b/containers/backupchecks/src/backend/app/main/routes_run_checks.py index 12ee4b0..71b7fbe 100644 --- a/containers/backupchecks/src/backend/app/main/routes_run_checks.py +++ b/containers/backupchecks/src/backend/app/main/routes_run_checks.py @@ -1068,14 +1068,11 @@ def run_checks_page(): JOIN ticket_scopes ts ON ts.ticket_id = t.id WHERE ts.job_id = :job_id AND t.active_from_date <= :run_date - AND ( - COALESCE(ts.resolved_at, t.resolved_at) IS NULL - OR ((COALESCE(ts.resolved_at, t.resolved_at) AT TIME ZONE 'UTC' AT TIME ZONE :ui_tz)::date) >= :run_date - ) + AND COALESCE(ts.resolved_at, t.resolved_at) IS NULL LIMIT 1 """ ), - {"job_id": job_id, "run_date": today_local, "ui_tz": ui_tz}, + {"job_id": job_id, "run_date": today_local}, ).first() has_active_ticket = bool(t_exists) @@ -1090,10 +1087,7 @@ def run_checks_page(): r.active_from_date, ((r.start_date AT TIME ZONE 'UTC' AT TIME ZONE :ui_tz)::date) ) <= :run_date - AND ( - r.resolved_at IS NULL - OR ((r.resolved_at AT TIME ZONE 'UTC' AT TIME ZONE :ui_tz)::date) >= :run_date - ) + AND r.resolved_at IS NULL LIMIT 1 """ ), diff --git a/docs/changelog-claude.md b/docs/changelog-claude.md index 4b68e62..cf284d4 100644 --- a/docs/changelog-claude.md +++ b/docs/changelog-claude.md @@ -8,6 +8,7 @@ This file documents all changes made to this project via Claude Code. - Fixed Autotask ticket not being automatically linked to new runs when internal ticket is resolved by implementing independent Autotask propagation strategy (now checks for most recent non-deleted and non-resolved Autotask ticket on job regardless of internal ticket status, ensuring PSA ticket reference persists across runs until explicitly resolved or deleted) - Fixed internal and Autotask tickets being linked to new runs even after being resolved by removing date-based "open" logic from ticket query (tickets now only link to new runs if they are genuinely unresolved, not based on run date comparisons) - Fixed Job Details page showing resolved tickets for ALL runs by implementing two-source ticket display: directly linked tickets (via ticket_job_runs) are always shown for audit trail, while active window tickets (via scope query) are only shown if unresolved, preserving historical ticket links while preventing resolved tickets from appearing on new runs +- Fixed Run Checks page showing resolved ticket indicators by removing date-based logic from ticket/remark existence queries (tickets and remarks now only show indicators if genuinely unresolved) ### Changed - Added debug logging to ticket linking function to troubleshoot resolved ticket propagation issues (writes to AuditLog table with event_type "ticket_link_debug", visible on Logging page, logs EVERY run import to show whether tickets were found and their resolved_at status, uses commit instead of flush to ensure persistence)