From a9cae0f8f54d964893818cfdbef8d9341e267512 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Tue, 10 Feb 2026 10:29:43 +0100 Subject: [PATCH] Fix Job Details page showing resolved tickets The Job Details page used the same date-based logic that was causing resolved tickets to appear for runs on the same day as the resolve date. The linking was already fixed in ticketing_utils.py, but the display query in routes_jobs.py still used the old logic, causing a mismatch: - New runs were correctly NOT linked to resolved tickets - But the UI still SHOWED resolved tickets due to the display query Changes: - Removed date-based OR clause from tickets query (line 201-204) - Removed date-based OR clause from remarks query (line 239-242) - Simplified query parameters (removed min_date and ui_tz) - Now both linking AND display use consistent logic: resolved = hidden Result: Resolved tickets and remarks no longer appear in Job Details or any other view, matching the expected behavior. Co-Authored-By: Claude Sonnet 4.5 --- .../src/backend/app/main/routes_jobs.py | 16 ++++------------ docs/changelog-claude.md | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/containers/backupchecks/src/backend/app/main/routes_jobs.py b/containers/backupchecks/src/backend/app/main/routes_jobs.py index 5bf5ebe..ef4e93b 100644 --- a/containers/backupchecks/src/backend/app/main/routes_jobs.py +++ b/containers/backupchecks/src/backend/app/main/routes_jobs.py @@ -198,14 +198,10 @@ def job_detail(job_id: int): JOIN ticket_scopes ts ON ts.ticket_id = t.id WHERE ts.job_id = :job_id AND t.active_from_date <= :max_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) >= :min_date - ) + AND COALESCE(ts.resolved_at, t.resolved_at) IS NULL """ ), - {"job_id": job.id, "min_date": min_date, - "ui_tz": _get_ui_timezone_name(), "max_date": max_date}, + {"job_id": job.id, "max_date": max_date}, ) .mappings() .all() @@ -240,14 +236,10 @@ def job_detail(job_id: int): r.active_from_date, ((r.start_date AT TIME ZONE 'UTC' AT TIME ZONE :ui_tz)::date) ) <= :max_date - AND ( - r.resolved_at IS NULL - OR ((r.resolved_at AT TIME ZONE 'UTC' AT TIME ZONE :ui_tz)::date) >= :min_date - ) + AND r.resolved_at IS NULL """ ), - {"job_id": job.id, "min_date": min_date, - "ui_tz": _get_ui_timezone_name(), "max_date": max_date}, + {"job_id": job.id, "max_date": max_date}, ) .mappings() .all() diff --git a/docs/changelog-claude.md b/docs/changelog-claude.md index 89f61cd..90a477b 100644 --- a/docs/changelog-claude.md +++ b/docs/changelog-claude.md @@ -7,6 +7,7 @@ This file documents all changes made to this project via Claude Code. ### Fixed - 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 in the Tickets column by removing date-based logic from display query (tickets and remarks now only show if genuinely unresolved, matching the linking behavior) ### 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)