Flow delete offers to delete its runs, history included

DELETE /runs?flow= removes every Run row of the flow but left its flow_run
rows, so a deleted flow kept appearing in the history. history=true now
drops those too, and the flow delete dialogs (editor and bulk) send it when
"Also delete its runs" is ticked.
This commit is contained in:
2026-10-15 10:52:33 +02:00
parent 7ea53ccf17
commit 6fa44bacf3
11 changed files with 124 additions and 18 deletions
+8 -1
View File
@@ -29,7 +29,7 @@ from fluksio.flow.events import event_bus
from fluksio.flow.messages import requalify
from fluksio.flow.runs import OUTPUT_CAP, RunRejected, RunService, new_run_id
from fluksio.flow.store import FlowNotFound
from fluksio.models import Message, Run, RunArtifact, RunMetric, RunNode
from fluksio.models import FlowRun, Message, Run, RunArtifact, RunMetric, RunNode
router = APIRouter(
prefix="/runs", tags=["runs"], dependencies=[Depends(get_current_user)]
@@ -881,6 +881,7 @@ def delete_runs(
session: SessionDep,
user: CurrentUser,
flow: Annotated[str, Query(min_length=1)],
history: bool = False,
) -> Any:
"""Every run of one flow at once.
@@ -888,6 +889,10 @@ def delete_runs(
deleting a flow leaves its runs standing on purpose, so this is the only
way to clear a history without a call per run. ``flow`` is required —
there is no "delete every run of everything" here, by design.
``history`` also drops the flow's rows in the run history (``flow_run``),
its cascades included. That is for a flow being deleted, which would
otherwise stay in the history until the retention window passes.
"""
with writing(session):
live = _live_run(session, flow)
@@ -906,6 +911,8 @@ def delete_runs(
select(func.count()).select_from(Run).where(col(Run.flow) == flow)
).one()
_drop_runs(session, chosen)
if history:
session.execute(delete(FlowRun).where(col(FlowRun.flow) == flow))
session.commit()
event_bus.publish(
{