/* 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 */ use super::{ error::MyError, layout::{DynLayoutPage, LayoutPage}, }; 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; #[get("/stats")] pub fn r_stats( sess: Session, db: &State, aj: AcceptJson, lang: AcceptLanguage, ) -> Result, Json>, MyError> { let AcceptLanguage(lang) = lang; let data = stats(db)?; Ok(if *aj { Either::Right(Json(data)) } else { Either::Left(1) }) }