blob: eb1e7048dcbec44e6b9e96c14b5a1f0fccc562f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
use http_body_util::Full;
use hyper::body::Bytes;
use hyper::Response;
use tera::Context;
use crate::controller::utils;
use crate::controller::wallet::Wallet;
use crate::db;
use crate::templates;
pub async fn get(wallet: &Wallet) -> Response<Full<Bytes>> {
let categories = db::categories::list(&wallet.pool).await;
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(),
);
context.insert("json_payments", &serde_json::to_string(&payments).unwrap());
context.insert("json_incomes", &serde_json::to_string(&incomes).unwrap());
utils::template(
&wallet.assets,
&wallet.templates,
"statistics.html",
context,
)
}
|