Compare commits

..

3 Commits

Author SHA1 Message Date
588f788e31 Auto-commit local changes before build (2026-02-10 11:49:48) 2026-02-10 11:49:48 +01:00
a919610d68 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>
2026-02-10 11:47:28 +01:00
da9ed8402e Merge branch 'v20260210-01-autotask-ticket-propagation-fix' into main
Release v0.1.26 - Ticket system bug fixes

This release resolves critical ticket system display issues where
resolved tickets were incorrectly appearing on new runs across
multiple pages.

Key changes:
- Fixed ticket propagation logic (4 locations)
- Transitioned from date-based to link-based queries
- Fixed Run Checks popup showing resolved tickets
- Updated Settings Maintenance UI text
- Test email generation reduced to 1 per button

Total commits: 10
Branch: v20260210-01-autotask-ticket-propagation-fix

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 11:36:01 +01:00
3 changed files with 5 additions and 6 deletions

View File

@ -1 +1 @@
v20260210-01-autotask-ticket-propagation-fix
main

View File

@ -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

View File

@ -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