b7cd2b1
use export::http::{Path, State};
use export::rest::AppResponseData;
use jwt::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, resolve_reader};
use crate::service::GitService;
use crate::service::packs::PackStatsDto;
#[utoipa::path(
get,
path = "/repos/{space_name}/{repo_name}/packs/stats",
tag = "packs",
description = "返回仓库松散对象数量与体积统计。",
params(RepoPath),
responses(
(status = 200, description = "pack statistics", body = AppResponseData<PackStatsDto>)
)
)]
pub async fn stats(
State(service): State<GitService>,
session: Session,
Path(path): Path<RepoPath>,
) -> Result<AppResponseData<PackStatsDto>, ApiError> {
resolve_reader(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.pack_stats(path.space_name, path.repo_name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}