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:
asepharyana
2026-08-04 23:09:08 +07:00
parent 9b5efeff87
commit 3692b81324
13 changed files with 181 additions and 22 deletions
@@ -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",