aboutsummaryrefslogtreecommitdiff
path: root/src/controller/statistics.rs
diff options
context:
space:
mode:
authorJoris2025-01-26 17:58:57 +0100
committerJoris2025-01-26 17:58:57 +0100
commit24eeb54a6b7159964e8887ade7fa5173b50feb3a (patch)
tree91af6253df784445db9b084b02b38b37a83224e8 /src/controller/statistics.rs
parentc5759f348e70cf54b4bfa4cd17e1fe1828ead30a (diff)
Replace tera by minijinjamain
tera was doing the job all right, but minijinja has fewer dependencies.
Diffstat (limited to 'src/controller/statistics.rs')
-rw-r--r--src/controller/statistics.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/controller/statistics.rs b/src/controller/statistics.rs
index eb1e704..e57e2be 100644
--- a/src/controller/statistics.rs
+++ b/src/controller/statistics.rs
@@ -1,7 +1,6 @@
use http_body_util::Full;
use hyper::body::Bytes;
use hyper::Response;
-use tera::Context;
use crate::controller::utils;
use crate::controller::wallet::Wallet;
@@ -13,15 +12,13 @@ pub async fn get(wallet: &Wallet) -> Response<Full<Bytes>> {
let payments = db::payments::list_for_stats(&wallet.pool).await;
let incomes = db::incomes::total_each_month(&wallet.pool).await;
- let mut context = Context::new();
- context.insert("header", &templates::Header::Statistics);
- context.insert("connected_user", &wallet.user);
- context.insert(
- "json_categories",
- &serde_json::to_string(&categories).unwrap(),
+ let context = minijinja::context!(
+ header => templates::Header::Statistics,
+ connected_user => wallet.user,
+ json_categories => serde_json::to_string(&categories).unwrap(),
+ json_payments => serde_json::to_string(&payments).unwrap(),
+ json_incomes => serde_json::to_string(&incomes).unwrap()
);
- context.insert("json_payments", &serde_json::to_string(&payments).unwrap());
- context.insert("json_incomes", &serde_json::to_string(&incomes).unwrap());
utils::template(
&wallet.assets,