Files
schedule-parser-rusted/src/routes/schedule/teacher_names.rs
n08i40k 5e39fc9acc feat(schedule)!: move schedule parser, downloader, and updater to external library
This can be used to support more schedule formats in the future.
2025-09-02 08:59:59 +04:00

36 lines
871 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use self::schema::*;
use crate::AppState;
use actix_web::{get, web};
#[utoipa::path(responses((status = OK, body = Response)))]
#[get("/teacher-names")]
pub async fn teacher_names(app_state: web::Data<AppState>) -> Response {
let mut names: Vec<String> = app_state
.get_schedule_snapshot("eng_polytechnic")
.await
.unwrap()
.data
.teachers
.keys()
.cloned()
.collect();
names.sort();
Response { names }
}
mod schema {
use actix_macros::ResponderJson;
use serde::Serialize;
use utoipa::ToSchema;
#[derive(Serialize, ToSchema, ResponderJson)]
#[schema(as = GetTeacherNames::Response)]
pub struct Response {
/// List of teacher names sorted alphabetically.
#[schema(examples(json!(["Хомченко Н.Е."])))]
pub names: Vec<String>,
}
}