use ::session::AuthedUser; use api::http::{Path, State}; use api::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; use crate::service::analysis::LanguageStatDto; #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/analysis/languages", tag = "analysis", description = "重新扫描仓库树并持久化语言构成与主语言统计。", params(crate::handler::RepoPath), responses( (status = 200, description = "analyze languages", body = AppResponseData>) ) )] pub async fn languages( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, ) -> Result>, ApiError> { let (ctx, _uid) = handler::require_writer( &service, uid, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .analysis_languages(&ctx) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }