aboutsummaryrefslogtreecommitdiff
path: root/ui/src/stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/stats.rs')
-rw-r--r--ui/src/stats.rs79
1 files changed, 0 insertions, 79 deletions
diff --git a/ui/src/stats.rs b/ui/src/stats.rs
deleted file mode 100644
index d69f07e..0000000
--- a/ui/src/stats.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- This file is part of jellything (https://codeberg.org/metamuffin/jellything)
- which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
- Copyright (C) 2026 metamuffin <metamuffin.org>
-*/
-
-use crate::{
- Page,
- format::{format_duration, format_duration_long, format_kind, format_size},
- locale::tr,
- scaffold::RenderInfo,
-};
-use jellycommon::routes::u_node_slug;
-use markup::raw;
-
-impl Page for StatsPage<'_> {
- fn title(&self) -> String {
- tr(self.ri.lang, "stats.title").to_string()
- }
- fn to_render(&self) -> markup::DynRender<'_> {
- markup::new!(@self)
- }
-}
-
-markup::define! {
- StatsPage<'a>(ri: &'a RenderInfo<'a>, r: ApiStatsResponse) {
- .page.stats {
- h1 { @tr(ri.lang, "stats.title") }
- p { @raw(tr(ri.lang, "stats.count")
- .replace("{count}", &format!("<b>{}</b>", r.total.count))
- )}
- p { @raw(tr(ri.lang, "stats.runtime")
- .replace("{dur}", &format!("<b>{}</b>", format_duration_long(r.total.runtime, ri.lang)))
- .replace("{size}", &format!("<b>{}</b>", format_size(r.total.size)))
- )}
- p { @raw(tr(ri.lang, "stats.average")
- .replace("{dur}", &format!("<b>{}</b>", format_duration(r.total.average_runtime())))
- .replace("{size}", &format!("<b>{}</b>", format_size(r.total.average_size() as u64)))
- )}
-
- h2 { @tr(ri.lang, "stats.by_kind.title") }
- table.striped {
- tr {
- th { @tr(ri.lang, "stats.by_kind.kind") }
- th { @tr(ri.lang, "stats.by_kind.count") }
- th { @tr(ri.lang, "stats.by_kind.total_size") }
- th { @tr(ri.lang, "stats.by_kind.total_runtime") }
- th { @tr(ri.lang, "stats.by_kind.average_size") }
- th { @tr(ri.lang, "stats.by_kind.average_runtime") }
- th { @tr(ri.lang, "stats.by_kind.max_size") }
- th { @tr(ri.lang, "stats.by_kind.max_runtime") }
- }
- @for (k,b) in &r.kinds { tr {
- td { @format_kind(*k, ri.lang) }
- td { @b.count }
- td { @format_size(b.size) }
- td { @format_duration(b.runtime) }
- td { @format_size(b.average_size() as u64) }
- td { @format_duration(b.average_runtime()) }
- td { @if b.max_size.0 > 0 { a[href=u_node_slug(&b.max_size.1)]{ @format_size(b.max_size.0) }}}
- td { @if b.max_runtime.0 > 0. { a[href=u_node_slug(&b.max_runtime.1)]{ @format_duration(b.max_runtime.0) }}}
- }}
- }
- }
- }
-}
-
-trait BinExt {
- fn average_runtime(&self) -> f64;
- fn average_size(&self) -> f64;
-}
-impl BinExt for StatsBin {
- fn average_runtime(&self) -> f64 {
- self.runtime / self.count as f64
- }
- fn average_size(&self) -> f64 {
- self.size as f64 / self.count as f64
- }
-}