HOTFIX: Fix duplicate tickets in Run Checks popup
Critical bug: Same ticket appeared multiple times in popup (e.g., T20260127.0061 showed 8 times). Root Cause: The JOIN with ticket_scopes/remark_scopes created duplicate rows when a ticket had multiple scopes (Cartesian product). Changes: - Removed unnecessary JOIN ticket_scopes from tickets query - Removed unnecessary JOIN remark_scopes from remarks query - Added DISTINCT to prevent any duplicate rows - Changed COALESCE(ts.resolved_at, t.resolved_at) to t.resolved_at (ticket_scopes JOIN removed, only ticket resolution matters) Result: Each ticket/remark now appears exactly once in popup. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
da9ed8402e
commit
a919610d68
@ -23,14 +23,13 @@ def api_job_run_alerts(run_id: int):
|
||||
db.session.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT t.id,
|
||||
SELECT DISTINCT t.id,
|
||||
t.ticket_code,
|
||||
t.description,
|
||||
t.start_date,
|
||||
COALESCE(ts.resolved_at, t.resolved_at) AS resolved_at,
|
||||
t.resolved_at,
|
||||
t.active_from_date
|
||||
FROM tickets t
|
||||
JOIN ticket_scopes ts ON ts.ticket_id = t.id
|
||||
JOIN ticket_job_runs tjr ON tjr.ticket_id = t.id
|
||||
WHERE tjr.job_run_id = :run_id
|
||||
ORDER BY t.start_date DESC
|
||||
@ -73,9 +72,8 @@ def api_job_run_alerts(run_id: int):
|
||||
db.session.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT r.id, r.body, r.start_date, r.resolved_at, r.active_from_date
|
||||
SELECT DISTINCT r.id, r.body, r.start_date, r.resolved_at, r.active_from_date
|
||||
FROM remarks r
|
||||
JOIN remark_scopes rs ON rs.remark_id = r.id
|
||||
JOIN remark_job_runs rjr ON rjr.remark_id = r.id
|
||||
WHERE rjr.job_run_id = :run_id
|
||||
ORDER BY r.start_date DESC
|
||||
|
||||
@ -10,6 +10,7 @@ This file documents all changes made to this project via Claude Code.
|
||||
- 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)
|
||||
- Fixed Run Checks popup showing resolved tickets for runs where they were never linked by replacing date-based ticket/remark queries in `/api/job-runs/<run_id>/alerts` endpoint with explicit link-based queries (now only shows tickets/remarks that were actually linked to the specific run via ticket_job_runs/remark_job_runs tables, completing the transition from date-based to explicit-link ticket system)
|
||||
- **HOTFIX**: Fixed Run Checks popup showing duplicate tickets (same ticket repeated multiple times) by removing unnecessary JOIN with ticket_scopes/remark_scopes tables and adding DISTINCT to prevent duplicate rows (root cause: tickets with multiple scopes created multiple result rows for same ticket via Cartesian product)
|
||||
|
||||
### 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) - **LATER REMOVED** after ticket system was fixed
|
||||
|
||||
Loading…
Reference in New Issue
Block a user