Skip to content
Clone
209a1c0
37 lines 1.1 KB Rust
use axum::extract::{Path, State};
use export::rest::AppResponseData;
use session_layer::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::resolve_reader;
use crate::service::GitService;
use crate::service::analysis::ContributorStatDto;
#[utoipa::path(
get,
path = "/repos/{space_name}/{repo_name}/analysis/contributors",
tag = "analysis",
description = "按提交数返回指定修订历史的贡献者及代码量统计。",
params(crate::handler::RepoPath),
responses(
(status = 200, description = "contributor statistics", body = AppResponseData<Vec<ContributorStatDto>>)
)
)]
pub async fn contributors(
State(service): State<GitService>,
session: Session,
Path(path): Path<crate::handler::RepoPath>,
) -> Result<AppResponseData<Vec<ContributorStatDto>>, ApiError> {
let _ = resolve_reader(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.analysis_contributors(path.space_name, path.repo_name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}