Skip to content

Commit d06f7cd

Browse files
committed
Filter out metric batches with "No Data" before sorting by alert count and average score
1 parent c99a7ca commit d06f7cd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

dashboard/routes.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ def index(request: Request):
5353

5454
batch_stats[batch_name] = calculate_batch_stats(df, batch_name)
5555

56-
# Sort the metric batches by alert count (primary) and avg score (secondary)
56+
# Filter out metric batches where latest_timestamp is "No Data"
57+
filtered_batches = {
58+
name: stats
59+
for name, stats in batch_stats.items()
60+
if stats["latest_timestamp"] != "No Data"
61+
}
62+
63+
# Sort the filtered metric batches by alert count (primary) and avg score (secondary)
5764
sorted_batch_names = sorted(
58-
app.state.metric_batches,
65+
filtered_batches.keys(),
5966
key=lambda x: (
60-
-batch_stats[x]["alert_count"], # Negative for descending order
61-
-batch_stats[x]["avg_score"] # Negative for descending order
67+
-filtered_batches[x]["alert_count"], # Negative for descending order
68+
-filtered_batches[x]["avg_score"] # Negative for descending order
6269
)
6370
)
6471

0 commit comments

Comments
 (0)