Files
pipelines/app/lib/features/runs/domain/run_tab_counts.dart
T
alan efca56e4e4 Show running and failed run counts independently
Give the Runs tab separate activity and failure indicators so neither suppresses the other. Reuse known summaries and pushed updates, keep failed states separate from decisions and dismissal counts, and update across tabs even when total attention is unchanged.
2026-11-11 22:10:37 +00:00

28 lines
803 B
Dart

import '../../../core/api_gateway.dart';
typedef RunTabCounts = ({int running, int failed});
/// Independent status counts from known, unfiltered server summaries.
/// Dismissing a notification does not change a run's failed status.
RunTabCounts runTabCounts(Iterable<JsonMap> runs) {
var running = 0;
var failed = 0;
for (final run in runs) {
if (run['status'] == 'failed') failed++;
if (const {
'succeeded',
'failed',
'canceled',
'interrupted',
}.contains(run['status'])) {
continue;
}
// Older summaries omit the execution flag but still name the live state.
if (run['executing'] == true ||
(!run.containsKey('executing') && run['status'] == 'running')) {
running++;
}
}
return (running: running, failed: failed);
}