From 98bb91680d27a65455a87b6ba1a59c3d7717fc4c Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Fri, 8 Mar 2024 15:32:14 +0100 Subject: [PATCH] httpd: Update stats to count all repos Instead of filtering private repos for a total count, we should count all repos. --- radicle-httpd/src/api/v1/stats.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/radicle-httpd/src/api/v1/stats.rs b/radicle-httpd/src/api/v1/stats.rs index d934f711..c8f4792b 100644 --- a/radicle-httpd/src/api/v1/stats.rs +++ b/radicle-httpd/src/api/v1/stats.rs @@ -2,7 +2,6 @@ use axum::extract::State; use axum::response::IntoResponse; use axum::routing::get; use axum::{Json, Router}; -use radicle::storage::ReadStorage as _; use serde_json::json; use crate::api::error::Error; @@ -17,12 +16,9 @@ pub fn router(ctx: Context) -> Router { /// Return the stats for the node. /// `GET /stats` async fn stats_handler(State(ctx): State) -> impl IntoResponse { - let storage = &ctx.profile.storage; - let projects = storage.inventory()?.len(); + let total = ctx.profile.storage.repositories()?.len(); - Ok::<_, Error>(Json( - json!({ "projects": { "count": projects }, "users": { "count": 0 } }), - )) + Ok::<_, Error>(Json(json!({ "repos": { "total": total } }))) } #[cfg(test)] @@ -39,16 +35,6 @@ mod routes { let response = get(&app, "/stats").await; assert_eq!(response.status(), StatusCode::OK); - assert_eq!( - response.json().await, - json!({ - "projects": { - "count": 1 - }, - "users": { - "count": 0 - } - }) - ); + assert_eq!(response.json().await, json!({ "repos": { "total": 2 } })); } }