Auto-commit local changes before build (2026-01-16 13:31:20)

This commit is contained in:
Ivo Oskamp 2026-01-16 13:31:20 +01:00
parent 487f923064
commit 25d1962f7b
3 changed files with 33 additions and 8 deletions

View File

@ -1 +1 @@
v20260116-06-runchecks-polling-merge-fix
v20260116-07-autotask-ticket-link-all-runs-ticketjobrun-fix

View File

@ -1145,20 +1145,38 @@ def api_run_checks_create_autotask_ticket():
# until it is explicitly resolved.
now = datetime.utcnow()
# Collect the open run IDs first (stable list), then apply updates and internal linking.
linked_run_ids: list[int] = []
try:
open_runs = (
rows = (
JobRun.query.filter(JobRun.job_id == run.job_id)
.filter(JobRun.reviewed_at.is_(None))
.with_entities(JobRun.id)
.order_by(JobRun.id.asc())
.all()
)
linked_run_ids = [int(rid) for (rid,) in rows if rid is not None]
except Exception:
open_runs = [run]
linked_run_ids = []
# Safety: always include the explicitly selected run.
if run not in (open_runs or []):
open_runs = (open_runs or []) + [run]
try:
if run.id and int(run.id) not in linked_run_ids:
linked_run_ids.append(int(run.id))
except Exception:
pass
# Load run objects for the IDs we determined.
open_runs = []
if linked_run_ids:
open_runs = JobRun.query.filter(JobRun.id.in_(linked_run_ids)).all()
else:
open_runs = [run]
try:
if run.id:
linked_run_ids = [int(run.id)]
except Exception:
linked_run_ids = []
for r in open_runs or []:
# Do not overwrite an existing (different) ticket linkage.
@ -1179,9 +1197,6 @@ def api_run_checks_create_autotask_ticket():
r.autotask_ticket_created_at = now
r.autotask_ticket_created_by_user_id = current_user.id
if getattr(r, "id", None):
linked_run_ids.append(int(r.id))
# Also store an internal Ticket record and link it to the run.
# This keeps Tickets/Remarks, Job Details, and Run Checks indicators consistent with the existing manual workflow.
internal_ticket = None
@ -1239,6 +1254,7 @@ def api_run_checks_create_autotask_ticket():
"ticket_id": int(run.autotask_ticket_id) if run.autotask_ticket_id else None,
"ticket_number": run.autotask_ticket_number or "",
"already_exists": False,
"linked_run_ids": linked_run_ids or [],
}
)

View File

@ -180,6 +180,15 @@ Changes:
- Ensured polled PSA ticket status is available again on the Run Checks page
- No changes made to ticket creation logic, resolution handling, or Backupchecks run state
## v20260116-07-autotask-ticket-link-all-runs-ticketjobrun-fix
### Changes:
- Fixed Autotask ticket creation linking so the internal TicketJobRun associations are created for all relevant open runs of the same job
- Ensured ticket numbers and ticket presence are consistently visible per run (Run Checks and Job Details), not only for the selected run
- Made the list of runs to link deterministic by collecting run IDs first, then applying both run field updates and internal ticket linking across that stable set
- No changes made to polling logic or PSA status interpretation
***
## v0.1.21