Auto-commit local changes before build (2026-01-19 16:27:38)
This commit is contained in:
parent
b56cdacf6b
commit
63526be592
@ -1 +1 @@
|
|||||||
v20260119-17-fix-autotask-postcreate-ticketnumber-internal-linking
|
v20260119-18-fix-legacy-ticketnumber-sync
|
||||||
|
|||||||
@ -49,6 +49,7 @@ def _ensure_internal_ticket_for_autotask(
|
|||||||
job: Job | None,
|
job: Job | None,
|
||||||
run_ids: list[int],
|
run_ids: list[int],
|
||||||
now: datetime,
|
now: datetime,
|
||||||
|
active_from_dt: datetime | None,
|
||||||
) -> Ticket | None:
|
) -> Ticket | None:
|
||||||
"""Best-effort: ensure an internal Ticket exists and is linked to the provided runs."""
|
"""Best-effort: ensure an internal Ticket exists and is linked to the provided runs."""
|
||||||
|
|
||||||
@ -59,8 +60,10 @@ def _ensure_internal_ticket_for_autotask(
|
|||||||
ticket = Ticket.query.filter(Ticket.ticket_code == code).first()
|
ticket = Ticket.query.filter(Ticket.ticket_code == code).first()
|
||||||
|
|
||||||
if ticket is None:
|
if ticket is None:
|
||||||
# Align with manual ticket creation: active_from_date is today (Amsterdam date).
|
# Align with manual ticket creation: active_from_date must be <= the run date
|
||||||
active_from = _to_amsterdam_date(now) or now.date()
|
# so legacy ticket visibility works for historical runs.
|
||||||
|
base_dt = active_from_dt or now
|
||||||
|
active_from = _to_amsterdam_date(base_dt) or base_dt.date()
|
||||||
ticket = Ticket(
|
ticket = Ticket(
|
||||||
ticket_code=code,
|
ticket_code=code,
|
||||||
description="",
|
description="",
|
||||||
@ -229,12 +232,19 @@ def _poll_autotask_ticket_states_for_runs(*, run_ids: list[int]) -> None:
|
|||||||
break
|
break
|
||||||
|
|
||||||
job = Job.query.get(runs_for_ticket[0].job_id) if runs_for_ticket else None
|
job = Job.query.get(runs_for_ticket[0].job_id) if runs_for_ticket else None
|
||||||
|
active_from_dt = None
|
||||||
|
try:
|
||||||
|
dts = [getattr(x, 'run_at', None) for x in runs_for_ticket if getattr(x, 'run_at', None)]
|
||||||
|
active_from_dt = min(dts) if dts else None
|
||||||
|
except Exception:
|
||||||
|
active_from_dt = None
|
||||||
_ensure_internal_ticket_for_autotask(
|
_ensure_internal_ticket_for_autotask(
|
||||||
ticket_number=tn,
|
ticket_number=tn,
|
||||||
job=job,
|
job=job,
|
||||||
run_ids=[int(x.id) for x in runs_for_ticket if getattr(x, "id", None)],
|
run_ids=[int(x.id) for x in runs_for_ticket if getattr(x, "id", None)],
|
||||||
now=now,
|
now=now,
|
||||||
)
|
active_from_dt=active_from_dt,
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Continue to missing-id fallback.
|
# Continue to missing-id fallback.
|
||||||
pass
|
pass
|
||||||
@ -268,6 +278,13 @@ def _poll_autotask_ticket_states_for_runs(*, run_ids: list[int]) -> None:
|
|||||||
|
|
||||||
job = Job.query.get(runs_for_ticket[0].job_id) if runs_for_ticket else None
|
job = Job.query.get(runs_for_ticket[0].job_id) if runs_for_ticket else None
|
||||||
|
|
||||||
|
active_from_dt = None
|
||||||
|
try:
|
||||||
|
dts = [getattr(x, 'run_at', None) for x in runs_for_ticket if getattr(x, 'run_at', None)]
|
||||||
|
active_from_dt = min(dts) if dts else None
|
||||||
|
except Exception:
|
||||||
|
active_from_dt = None
|
||||||
|
|
||||||
tn = (str(ticket_number).strip() if ticket_number else "")
|
tn = (str(ticket_number).strip() if ticket_number else "")
|
||||||
if not tn:
|
if not tn:
|
||||||
for rr in runs_for_ticket:
|
for rr in runs_for_ticket:
|
||||||
@ -280,6 +297,7 @@ def _poll_autotask_ticket_states_for_runs(*, run_ids: list[int]) -> None:
|
|||||||
job=job,
|
job=job,
|
||||||
run_ids=[int(x.id) for x in runs_for_ticket if getattr(x, "id", None)],
|
run_ids=[int(x.id) for x in runs_for_ticket if getattr(x, "id", None)],
|
||||||
now=now,
|
now=now,
|
||||||
|
active_from_dt=active_from_dt,
|
||||||
)
|
)
|
||||||
|
|
||||||
# If terminal in PSA: resolve internally.
|
# If terminal in PSA: resolve internally.
|
||||||
@ -1373,7 +1391,7 @@ def api_run_checks_create_autotask_ticket():
|
|||||||
|
|
||||||
# Create/repair internal Ticket + TicketJobRun links (legacy UI compatibility).
|
# Create/repair internal Ticket + TicketJobRun links (legacy UI compatibility).
|
||||||
if ticket_number_str:
|
if ticket_number_str:
|
||||||
_ensure_internal_ticket_for_autotask(ticket_number=ticket_number_str, job=job, run_ids=run_ids, now=now)
|
_ensure_internal_ticket_for_autotask(ticket_number=ticket_number_str, job=job, run_ids=run_ids, now=now, active_from_dt=getattr(run, 'run_at', None) or now)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.session.add(run)
|
db.session.add(run)
|
||||||
|
|||||||
@ -324,6 +324,23 @@ Changes:
|
|||||||
- Replaced the obsolete `renderModal(...)` call with the correct Run Checks rendering function.
|
- Replaced the obsolete `renderModal(...)` call with the correct Run Checks rendering function.
|
||||||
- Restored proper Run Checks page rendering without breaking existing ticket or modal behaviour.
|
- Restored proper Run Checks page rendering without breaking existing ticket or modal behaviour.
|
||||||
|
|
||||||
|
## v20260119-17-fix-autotask-postcreate-ticketnumber-internal-linking
|
||||||
|
|
||||||
|
### Changes:
|
||||||
|
- Enforced mandatory post-create retrieval (GET Tickets/{TicketID}) after Autotask ticket creation to reliably obtain the Ticket Number.
|
||||||
|
- Persisted the retrieved Ticket Number to all active (unreviewed) runs of the same job when missing.
|
||||||
|
- Restored automatic creation and repair of internal Ticket records once the Ticket Number is known.
|
||||||
|
- Restored TicketJobRun linking so Autotask-created tickets appear correctly in Tickets, Remarks, and Job Details.
|
||||||
|
- Prevented UI state where a ticket was shown as “created” without a Ticket Number or internal ticket linkage.
|
||||||
|
|
||||||
|
## v20260119-18-fix-legacy-ticketnumber-sync
|
||||||
|
|
||||||
|
### Changes:
|
||||||
|
- Restored legacy ticket number compatibility by aligning internal Ticket activation timing with the original run date.
|
||||||
|
- Set internal Ticket `active_from_date` based on the earliest associated run timestamp instead of the current date.
|
||||||
|
- Ensured legacy ticket visibility and numbering work correctly for historical runs across Tickets, Remarks, Job Details, and Run Checks indicators.
|
||||||
|
- Applied the same logic during post-create processing and Phase 2 polling repair to keep legacy behaviour consistent and idempotent.
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
## v0.1.21
|
## v0.1.21
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user