27 lines
959 B
Rust
27 lines
959 B
Rust
use crate::{ApiResponse, error::ApiError};
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use service::project::stats::ProjectStatsResponse;
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/projects/{project_name}/stats",
|
|
params(("project_name" = String, Path)),
|
|
responses(
|
|
(status = 200, description = "Get project statistics", body = ApiResponse<ProjectStatsResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
(status = 403, description = "Forbidden — no access to this project"),
|
|
(status = 404, description = "Project not found"),
|
|
),
|
|
tag = "Project"
|
|
)]
|
|
pub async fn project_stats(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
path: web::Path<String>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let project_name = path.into_inner();
|
|
let resp = service.project_stats(&session, project_name).await?;
|
|
Ok(ApiResponse::ok(resp).to_response())
|
|
} |