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
@@ -1,6 +1,7 @@
use super::handlers::{
get_mentor_availability, get_mentor_sessions, get_my_sessions, post_book_session,
post_submit_feedback, put_update_session_status,
get_mentor_availability, get_mentor_sessions, get_mentor_stats,
get_my_sessions, post_book_session, post_submit_feedback,
put_update_session_status,
};
use crate::sessions::application::SessionServiceImpl;
use crate::sessions::domain::SessionService;
@@ -14,14 +15,16 @@ use sea_orm::DatabaseConnection;
use std::sync::Arc;
fn build_service(db: DatabaseConnection) -> Arc<dyn SessionService> {
let repo = Arc::new(PostgresSessionRepository::new(db));
Arc::new(SessionServiceImpl::new(repo))
let db_arc = Arc::new(db);
let repo = Arc::new(PostgresSessionRepository::new(Arc::clone(&db_arc)));
Arc::new(SessionServiceImpl::new(repo, db_arc))
}
pub fn sessions_public_routes(db: DatabaseConnection) -> Router {
let service = build_service(db);
Router::new()
.route("/mentors/{id}/availability", get(get_mentor_availability))
.route("/mentors/{id}/stats", get(get_mentor_stats))
.layer(Extension(service))
}