blob: ff02e33b672ea87175ee4f3a17dba9a12be23b62 (
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
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use super::error::MyError;
use crate::helper::RequestInfo;
use jellycommon::api::ApiStatsResponse;
use jellylogic::stats::stats;
use jellyui::{render_page, stats::StatsPage};
use rocket::{get, response::content::RawHtml, serde::json::Json, Either};
#[get("/stats")]
pub fn r_stats(
ri: RequestInfo,
) -> Result<Either<RawHtml<String>, Json<ApiStatsResponse>>, MyError> {
let r = stats(&ri.session)?;
Ok(if ri.accept.is_json() {
Either::Right(Json(r))
} else {
Either::Left(RawHtml(render_page(
&StatsPage { lang: &ri.lang, r },
ri.render_info(),
)))
})
}
|