mirror of
https://github.com/getnora-io/nora.git
synced 2026-04-12 09:10:32 +00:00
ui: group consecutive identical activity entries
Repeated cache hits for the same artifact now show as "artifact (x4)" instead of 4 identical rows. Reduces visual noise in dashboard activity log.
This commit is contained in:
@@ -74,17 +74,44 @@ pub fn render_dashboard(data: &DashboardResponse, lang: Lang) -> String {
|
|||||||
t.no_activity
|
t.no_activity
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
data.activity
|
// Group consecutive identical entries (same action+artifact+registry+source)
|
||||||
.iter()
|
let mut grouped: Vec<(String, String, String, String, String, usize)> = Vec::new();
|
||||||
.map(|entry| {
|
for entry in &data.activity {
|
||||||
|
let action = entry.action.to_string();
|
||||||
|
let last_match = grouped
|
||||||
|
.last()
|
||||||
|
.map(|(_, a, art, reg, src, _)| {
|
||||||
|
*a == action
|
||||||
|
&& *art == entry.artifact
|
||||||
|
&& *reg == entry.registry
|
||||||
|
&& *src == entry.source
|
||||||
|
})
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
if last_match {
|
||||||
|
grouped.last_mut().unwrap().5 += 1;
|
||||||
|
} else {
|
||||||
let time_ago = format_relative_time(&entry.timestamp);
|
let time_ago = format_relative_time(&entry.timestamp);
|
||||||
render_activity_row(
|
grouped.push((
|
||||||
&time_ago,
|
time_ago,
|
||||||
&entry.action.to_string(),
|
action,
|
||||||
&entry.artifact,
|
entry.artifact.clone(),
|
||||||
&entry.registry,
|
entry.registry.clone(),
|
||||||
&entry.source,
|
entry.source.clone(),
|
||||||
)
|
1,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grouped
|
||||||
|
.iter()
|
||||||
|
.map(|(time, action, artifact, registry, source, count)| {
|
||||||
|
let display_artifact = if *count > 1 {
|
||||||
|
format!("{} (x{})", artifact, count)
|
||||||
|
} else {
|
||||||
|
artifact.clone()
|
||||||
|
};
|
||||||
|
render_activity_row(time, action, &display_artifact, registry, source)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user