Skip to content

Automations UI polish: edit action and batch job stats - #2299

Draft
Flix6x wants to merge 6 commits into
feat/2288-report-automationsfrom
feat/2288-automations-ui-polish
Draft

Automations UI polish: edit action and batch job stats#2299
Flix6x wants to merge 6 commits into
feat/2288-report-automationsfrom
feat/2288-automations-ui-polish

Conversation

@Flix6x

@Flix6x Flix6x commented Jul 11, 2026

Copy link
Copy Markdown
Member

Description

Follow-ups on the automations UI (stacked on #2297):

  • Edit action: the automations page gets a per-row Edit button opening a modal to change the name and cron string (via the existing PATCH endpoint), completing the UI CRUD story.
  • Batch job stats: GET /assets/<id>/automations now includes per-automation job_stats, computed in a single pass over the relevant job caches (deduped cache refs across all the asset's automations, jobs grouped by their trigger's automation id). The UI fills the Jobs column from the list response instead of firing one detail request per automation on page load, and the Details modal loads its contents lazily when first opened. This resolves the O(automations × sensors × jobs) Redis fanout flagged in the Automations - first roundtrip for forecasts #2290 review.
  • The list response also surfaces redis_connection_err, like the jobs endpoint.

How to test

Open /assets/<id>/automations as an account admin: the Jobs column fills immediately from one request; Edit lets you rename/re-schedule.

Tests: pytest flexmeasures/api/v3_0/tests/test_automations_api.py flexmeasures/cli/tests/test_automations.py flexmeasures/ui/tests/test_asset_crud.py

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX

- The automations page gets an Edit action (name and cron string), using the
  existing PATCH endpoint.
- The list endpoint now includes per-automation job stats, computed in a
  single pass over the relevant job caches, instead of the UI firing one
  detail request per automation on page load; the Details modal loads its
  contents lazily, when first opened.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Flix6x and others added 5 commits July 11, 2026 22:25
…s-ui-polish

# Conflicts:
#	flexmeasures/data/services/automations.py
Context:

PR #2299 was based on an earlier revision of the report automation stack and conflicted with the newer timezone, activation, report sensor, and error-handling behavior.

Change:

Merge the current report automation branch while retaining the batched job-stat listing and lazy detail loading. The reconciled editor continues to update name, recurrence, timezone, and activation state.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:

The batched automation listing failed with HTTP 500 on Redis timeouts and schedule statistics only scanned sensors named in stored parameters. A minimal schedule can inherit device sensors from descendant assets, so its child jobs were omitted.

Change:

Treat Redis client failures as unavailable statistics while returning the automation list with a stable public error. Scan scheduling cache entries for the complete asset subtree once per listing, while continuing to deduplicate jobs cached under multiple entities.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:

The existing coverage proved only duplicate suppression for one schedule job and assumed Redis failures always used the service wrapper exception. It did not exercise a distinct descendant job or a real Redis client timeout.

Change:

Verify that distinct child-sensor schedule jobs are counted while duplicate cache references remain deduplicated. Verify that a Redis timeout leaves the list response usable, clears statistics, exposes a safe message, and does not leak connection details.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:

PR #2299 changes the automation list contract and the UI interaction model, but the branch had no user-facing or API changelog entry for those additions.

Change:

Document the batched job counts, lazy detail loading, complete recurrence editor, and Redis-unavailable response behavior in the main and API changelogs.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants