49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
use crate::{ApiResponse, error::ApiError};
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/users/{username}/heatmap",
|
|
params(("username" = String, Path)),
|
|
responses(
|
|
(status = 200, description = "Get contribution heatmap", body = ApiResponse<service::user::chpc::ContributionHeatmapResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
(status = 404, description = "Not found"),
|
|
),
|
|
tag = "User"
|
|
)]
|
|
pub async fn get_contribution_heatmap(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
path: web::Path<String>,
|
|
query: web::Query<service::user::chpc::ContributionHeatmapQuery>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let username = path.into_inner();
|
|
let resp = service
|
|
.get_user_contribution_heatmap(session, username, query.into_inner())
|
|
.await?;
|
|
Ok(ApiResponse::ok(resp).to_response())
|
|
}
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/users/me/heatmap",
|
|
responses(
|
|
(status = 200, description = "Get my contribution heatmap", body = ApiResponse<service::user::chpc::ContributionHeatmapResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
),
|
|
tag = "User"
|
|
)]
|
|
pub async fn get_my_contribution_heatmap(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
query: web::Query<service::user::chpc::ContributionHeatmapQuery>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let resp = service
|
|
.get_current_user_contribution_heatmap(session, query.into_inner())
|
|
.await?;
|
|
Ok(ApiResponse::ok(resp).to_response())
|
|
}
|