diff --git a/source/scss/common.scss b/source/scss/common.scss
index f32797d..7e4801b 100644
--- a/source/scss/common.scss
+++ b/source/scss/common.scss
@@ -65,3 +65,7 @@ details {
.underline {
text-decoration: underline;
}
+
+.small {
+ font-size: 1rem;
+}
diff --git a/source/templates/index.html b/source/templates/index.html
index 4311307..905f81a 100644
--- a/source/templates/index.html
+++ b/source/templates/index.html
@@ -44,7 +44,11 @@
{{ group.name }}
|
- {{ group.subscribers }} |
+
+ {{ group.subscribers }} ({{ group.subscribers|percentage(user_count) }})
+ |
{% if let Some(description) = group.description %}
{{ description }}
diff --git a/source/templates/mod.rs b/source/templates/mod.rs
index 6ac0e70..dfd0b36 100644
--- a/source/templates/mod.rs
+++ b/source/templates/mod.rs
@@ -40,7 +40,7 @@ pub struct HomeTemplate {
pub today: NaiveDate,
/// The user count from the group with the most subscribers.
- pub user_count: String,
+ pub user_count: i64,
}
impl HomeTemplate {
@@ -59,9 +59,7 @@ impl HomeTemplate {
groups,
page_title: "Tildes Statistics".to_string(),
today: today(),
- user_count: user_count
- .map(|n| n.to_string())
- .unwrap_or_else(|| "unknown".to_string()),
+ user_count: user_count.unwrap_or(1),
}
}
@@ -128,3 +126,10 @@ impl GroupTemplate {
Ok(())
}
}
+
+mod filters {
+ pub fn percentage(a: &i64, b: &i64) -> askama::Result {
+ let percentage = (*a as f64 / *b as f64) * 100_f64;
+ Ok(format!("{:.2}%", percentage))
+ }
+}
|