aboutsummaryrefslogtreecommitdiff
path: root/server/src/ui/stats.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-29 11:10:21 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-29 11:10:21 +0200
commitf62c7f2a8cc143454779dc99334ca9fc80ddabd5 (patch)
treef31dbb908715d2deb2860e2097fa13dd41d759d5 /server/src/ui/stats.rs
parent73d2d5eb01fceae9e0b1c58afb648822000c878a (diff)
downloadjellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar
jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.bz2
jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.zst
still just moving code around
Diffstat (limited to 'server/src/ui/stats.rs')
-rw-r--r--server/src/ui/stats.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/server/src/ui/stats.rs b/server/src/ui/stats.rs
index a91e670..8bfecbf 100644
--- a/server/src/ui/stats.rs
+++ b/server/src/ui/stats.rs
@@ -3,38 +3,38 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use super::{
- error::MyError,
- layout::{DynLayoutPage, LayoutPage},
+use super::error::MyError;
+use crate::{api::AcceptJson, database::Database, locale::AcceptLanguage};
+use jellycommon::api::ApiStatsResponse;
+use jellyimport::is_importing;
+use jellylogic::{session::Session, stats::stats};
+use jellyui::{
+ render_page,
+ scaffold::{RenderInfo, SessionInfo},
+ stats::StatsPage,
};
-use crate::{
- api::AcceptJson, database::Database, locale::AcceptLanguage, logic::session::Session, uri,
-};
-use jellybase::locale::tr;
-use jellycommon::{
- api::{ApiStatsResponse, StatsBin},
- Node, NodeID, NodeKind, Visibility,
-};
-use jellylogic::stats::stats;
-use markup::raw;
-use rocket::{get, serde::json::Json, Either, State};
-use serde::Serialize;
-use serde_json::{json, Value};
-use std::collections::BTreeMap;
+use rocket::{get, response::content::RawHtml, serde::json::Json, Either, State};
#[get("/stats")]
pub fn r_stats(
- sess: Session,
+ session: Session,
db: &State<Database>,
aj: AcceptJson,
lang: AcceptLanguage,
-) -> Result<Either<DynLayoutPage<'_>, Json<ApiStatsResponse>>, MyError> {
+) -> Result<Either<RawHtml<String>, Json<ApiStatsResponse>>, MyError> {
let AcceptLanguage(lang) = lang;
- let data = stats(db)?;
+ let r = stats(db, &session)?;
Ok(if *aj {
- Either::Right(Json(data))
+ Either::Right(Json(r))
} else {
- Either::Left(1)
+ Either::Left(RawHtml(render_page(
+ &StatsPage { lang: &lang, r },
+ RenderInfo {
+ importing: is_importing(),
+ session: Some(SessionInfo { user: session.user }),
+ },
+ lang,
+ )))
})
}