fix: tab state persists in url hash. Settings save nolonger reload the page. Scheduler management now cascades to individual events.

This commit is contained in:
serversdwn
2026-02-04 18:12:18 +00:00
parent f296806fd1
commit e515bff1a9
3 changed files with 59 additions and 7 deletions

View File

@@ -330,19 +330,35 @@ async def disable_schedule(
db: Session = Depends(get_db),
):
"""
Disable a schedule.
Disable a schedule and cancel all its pending actions.
"""
service = get_recurring_schedule_service(db)
# Count pending actions before disabling (for response message)
from sqlalchemy import and_
from backend.models import ScheduledAction
pending_count = db.query(ScheduledAction).filter(
and_(
ScheduledAction.execution_status == "pending",
ScheduledAction.notes.like(f'%"schedule_id": "{schedule_id}"%'),
)
).count()
schedule = service.disable_schedule(schedule_id)
if not schedule:
raise HTTPException(status_code=404, detail="Schedule not found")
message = "Schedule disabled"
if pending_count > 0:
message += f" and {pending_count} pending action(s) cancelled"
return {
"success": True,
"schedule_id": schedule.id,
"enabled": schedule.enabled,
"message": "Schedule disabled",
"cancelled_actions": pending_count,
"message": message,
}