Fix Autotask and internal tickets not linking to missed runs
Added ticket linking to missed runs by calling link_open_internal_tickets_to_run after creating missed JobRun records in _ensure_missed_runs_for_job function. Changes: - Added import for link_open_internal_tickets_to_run in routes_run_checks.py - Added db.session.flush() and ticket linking call after creating weekly missed runs - Added db.session.flush() and ticket linking call after creating monthly missed runs - Ensures missed runs receive same ticket propagation as email-based runs This fixes the issue where missed runs were not showing linked internal tickets or Autotask tickets, while error/warning runs from emails were working correctly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0e1e7e053d
commit
6468cbbc74
@ -38,6 +38,7 @@ from ..models import (
|
|||||||
TicketScope,
|
TicketScope,
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
|
from ..ticketing_utils import link_open_internal_tickets_to_run
|
||||||
|
|
||||||
|
|
||||||
AUTOTASK_TERMINAL_STATUS_IDS = {5}
|
AUTOTASK_TERMINAL_STATUS_IDS = {5}
|
||||||
@ -725,6 +726,8 @@ def _ensure_missed_runs_for_job(job: Job, start_from: date, end_inclusive: date)
|
|||||||
mail_message_id=None,
|
mail_message_id=None,
|
||||||
)
|
)
|
||||||
db.session.add(miss)
|
db.session.add(miss)
|
||||||
|
db.session.flush() # Ensure miss.id is available for ticket linking
|
||||||
|
link_open_internal_tickets_to_run(run=miss, job=job)
|
||||||
inserted += 1
|
inserted += 1
|
||||||
|
|
||||||
d = d + timedelta(days=1)
|
d = d + timedelta(days=1)
|
||||||
@ -806,6 +809,8 @@ def _ensure_missed_runs_for_job(job: Job, start_from: date, end_inclusive: date)
|
|||||||
mail_message_id=None,
|
mail_message_id=None,
|
||||||
)
|
)
|
||||||
db.session.add(miss)
|
db.session.add(miss)
|
||||||
|
db.session.flush() # Ensure miss.id is available for ticket linking
|
||||||
|
link_open_internal_tickets_to_run(run=miss, job=job)
|
||||||
inserted += 1
|
inserted += 1
|
||||||
|
|
||||||
# Next month
|
# Next month
|
||||||
|
|||||||
@ -5,7 +5,7 @@ This file documents all changes made to this project via Claude Code.
|
|||||||
## [2026-02-13]
|
## [2026-02-13]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed Autotask internal tickets not being linked to new runs (issue from 2026-02-11 now resolved)
|
- Fixed Autotask tickets and internal tickets not being linked to missed runs by calling `link_open_internal_tickets_to_run` after creating missed JobRun records in `_ensure_missed_runs_for_job` (both weekly and monthly schedules), ensuring missed runs now receive the same ticket propagation as email-based runs
|
||||||
|
|
||||||
## [2026-02-12]
|
## [2026-02-12]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user