diff --git a/src/handlers.rs b/src/handlers.rs index bc2df83..7bd4ed6 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -14,6 +14,7 @@ use crate::{AppState, TEMPLATES}; pub struct SortParams { pub sort: Option, pub order: Option, + pub experimental: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -41,6 +42,7 @@ pub struct ReportRow { pub time_ago: String, pub timestamp: String, pub signature: String, + pub client_version: String, pub is_new: bool, } @@ -139,6 +141,7 @@ fn process_reports(raw_reports: Vec) -> Vec { signature: s.signature, timestamp: s.timestamp.clone(), time_ago: format_time_ago(&s.timestamp), + client_version: s.client_version, is_new: is_recent(&s.timestamp), } }) @@ -193,6 +196,11 @@ pub async fn home_handler( let raw_reports = get_cached_reports(&state).await?; let mut reports = process_reports(raw_reports); + let show_experimental = params.experimental.as_deref() == Some("true"); + if !show_experimental { + reports.retain(|r| !r.client_version.starts_with("Android")); + } + let sort_field = params.sort.unwrap_or_else(|| "score".to_string()); let order = params.order.unwrap_or_else(|| "desc".to_string()); @@ -216,6 +224,7 @@ pub async fn home_handler( context.insert("title", &state.app_name); context.insert("current_sort", &sort_field); context.insert("current_order", &order); + context.insert("show_experimental", &show_experimental); context.insert("current_page", "leaderboard"); context.insert("prefix", ""); diff --git a/templates/_layout.html b/templates/_layout.html index faad9e1..ecda191 100644 --- a/templates/_layout.html +++ b/templates/_layout.html @@ -22,23 +22,23 @@