From 8f731106364bf828747af7e6177cc447a69a56d9 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 28 Apr 2024 22:59:20 +0200 Subject: show leaderboard --- src/info.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/info.rs') diff --git a/src/info.rs b/src/info.rs index c3fa0a9..1e5d8d9 100644 --- a/src/info.rs +++ b/src/info.rs @@ -1,10 +1,13 @@ -use crate::{s_file, Template}; +use crate::error::MyResult; +use crate::{s_file, state::Logic, Template}; use markup::{doctype, DynRender}; -use rocket::{get, http::ContentType}; +use rocket::{get, http::ContentType, State}; +use std::sync::Arc; #[get("/")] -pub fn r_index<'a>() -> Template> { - Template(markup::new! { +pub async fn r_index<'a>(state: &State>) -> MyResult>> { + let leaderboard = state.get_leaderboard().await?; + Ok(Template(markup::new! { @doctype() html { head { @@ -41,6 +44,17 @@ pub fn r_index<'a>() -> Template> { li { "The image, URL or names should be free of malware" } } } + h2 { "leaderboard" } + table { + tr { th { "Domain" } th { "Impressions" } th { "Impression weight" } } + @for (domain, raw, weighted) in &leaderboard { + tr { + td { @domain } + td { @raw } + td { @weighted } + } + } + } h2 { "privacy" } p { "data used by meta adservices: " } ul { @@ -54,7 +68,7 @@ pub fn r_index<'a>() -> Template> { } } } - }) + })) } #[get("/style.css")] -- cgit v1.2.3-70-g09d2