feat(dimentorin): mentor stats endpoint public - total sessions, unique mentees, avg rating
- GET /mentors/{id}/stats (public, no auth)
- resolve mentor profile id -> user id in get_mentor_sessions (FK uses app_users.id)
This commit is contained in:
@@ -5,5 +5,5 @@ pub use mutation_handlers::{
|
||||
post_book_session, post_submit_feedback, put_update_session_status,
|
||||
};
|
||||
pub use query_handlers::{
|
||||
get_mentor_availability, get_mentor_sessions, get_my_sessions,
|
||||
get_mentor_availability, get_mentor_sessions, get_mentor_stats, get_my_sessions,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::super::dto::{MentorAvailabilityDto, SessionListResponseDto};
|
||||
use super::super::dto::{MentorAvailabilityDto, MentorStatsDto, SessionListResponseDto};
|
||||
use crate::sessions::domain::SessionService;
|
||||
use axum::{
|
||||
extract::{Extension, Path, Query},
|
||||
@@ -68,6 +68,25 @@ pub async fn get_mentor_availability(
|
||||
Ok(ApiSuccess(resp))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/dimentorin/mentors/{id}/stats",
|
||||
tag = "sessions",
|
||||
params(
|
||||
("id" = String, Path, description = "Mentor id"),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Mentor stats retrieved successfully", body = MentorStatsDto),
|
||||
)
|
||||
)]
|
||||
pub async fn get_mentor_stats(
|
||||
Extension(service): Extension<Arc<dyn SessionService>>,
|
||||
Path(mentor_id): Path<String>,
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
let resp = MentorStatsDto::from(service.get_mentor_stats(mentor_id).await?);
|
||||
Ok(ApiSuccess(resp))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/dimentorin/sessions/me",
|
||||
|
||||
Reference in New Issue
Block a user