mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
Обновление документации.
This commit is contained in:
@@ -25,10 +25,7 @@ use actix_web::{get, web};
|
||||
),
|
||||
))]
|
||||
#[get("/group")]
|
||||
pub async fn group(
|
||||
user: SyncExtractor<User>,
|
||||
app_state: web::Data<AppState>,
|
||||
) -> ServiceResponse {
|
||||
pub async fn group(user: SyncExtractor<User>, app_state: web::Data<AppState>) -> ServiceResponse {
|
||||
// Prevent thread lock
|
||||
let schedule_lock = app_state.schedule.lock().unwrap();
|
||||
|
||||
@@ -55,22 +52,22 @@ mod schema {
|
||||
#[schema(as = GetGroup::Response)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Response {
|
||||
/// Расписание группы
|
||||
/// Group schedule.
|
||||
pub group: ScheduleEntry,
|
||||
|
||||
/// Устаревшая переменная
|
||||
///
|
||||
/// По умолчанию возвращается пустой список
|
||||
|
||||
/// ## Outdated variable.
|
||||
///
|
||||
/// By default, an empty list is returned.
|
||||
#[deprecated = "Will be removed in future versions"]
|
||||
pub updated: Vec<i32>,
|
||||
|
||||
/// Устаревшая переменная
|
||||
/// ## Outdated variable.
|
||||
///
|
||||
/// По умолчанию начальная дата по Unix
|
||||
/// By default, the initial date for unix.
|
||||
#[deprecated = "Will be removed in future versions"]
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl From<ScheduleEntry> for Response {
|
||||
fn from(group: ScheduleEntry) -> Self {
|
||||
@@ -86,12 +83,12 @@ mod schema {
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[schema(as = GroupSchedule::ErrorCode)]
|
||||
pub enum ErrorCode {
|
||||
/// Расписания ещё не получены
|
||||
/// Schedules have not yet been parsed.
|
||||
#[status_code = "actix_web::http::StatusCode::SERVICE_UNAVAILABLE"]
|
||||
#[display("Schedule not parsed yet.")]
|
||||
NoSchedule,
|
||||
|
||||
/// Группа не найдена
|
||||
/// Group not found.
|
||||
#[status_code = "actix_web::http::StatusCode::NOT_FOUND"]
|
||||
#[display("Required group not found.")]
|
||||
NotFound,
|
||||
|
||||
@@ -35,7 +35,7 @@ mod schema {
|
||||
#[derive(Serialize, ToSchema)]
|
||||
#[schema(as = GetGroupNames::Response)]
|
||||
pub struct Response {
|
||||
/// Список названий групп отсортированный в алфавитном порядке
|
||||
/// List of group names sorted in alphabetical order.
|
||||
#[schema(examples(json!(["ИС-214/23"])))]
|
||||
pub names: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -8,23 +8,23 @@ use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Ответ от сервера с расписаниями
|
||||
/// Response from schedule server.
|
||||
#[derive(Serialize, ToSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ScheduleView {
|
||||
/// ETag расписания на сервере политехникума
|
||||
/// ETag schedules on polytechnic server.
|
||||
etag: String,
|
||||
|
||||
/// Дата обновления расписания на сайте политехникума
|
||||
|
||||
/// Schedule update date on polytechnic website.
|
||||
uploaded_at: DateTime<Utc>,
|
||||
|
||||
/// Дата последнего скачивания расписания с сервера политехникума
|
||||
|
||||
/// Date last downloaded from the Polytechnic server.
|
||||
downloaded_at: DateTime<Utc>,
|
||||
|
||||
/// Расписание групп
|
||||
|
||||
/// Groups schedule.
|
||||
groups: HashMap<String, ScheduleEntry>,
|
||||
|
||||
/// Расписание преподавателей
|
||||
|
||||
/// Teachers schedule.
|
||||
teachers: HashMap<String, ScheduleEntry>,
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ pub struct ScheduleView {
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[schema(as = ScheduleShared::ErrorCode)]
|
||||
pub enum ErrorCode {
|
||||
/// Расписания ещё не получены
|
||||
/// Schedules not yet parsed.
|
||||
#[display("Schedule not parsed yet.")]
|
||||
NoSchedule,
|
||||
}
|
||||
@@ -56,22 +56,22 @@ impl TryFrom<&web::Data<AppState>> for ScheduleView {
|
||||
}
|
||||
}
|
||||
|
||||
/// Статус кешированного расписаний
|
||||
/// Cached schedule status.
|
||||
#[derive(Serialize, Deserialize, ToSchema, ResponderJson)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CacheStatus {
|
||||
/// Хеш расписаний
|
||||
/// Schedule hash.
|
||||
pub cache_hash: String,
|
||||
|
||||
/// Требуется ли обновить ссылку на расписание
|
||||
|
||||
/// Whether the schedule reference needs to be updated.
|
||||
pub cache_update_required: bool,
|
||||
|
||||
/// Дата последнего обновления кеша
|
||||
|
||||
/// Last cache update date.
|
||||
pub last_cache_update: i64,
|
||||
|
||||
/// Дата обновления кешированного расписания
|
||||
///
|
||||
/// Определяется сервером политехникума
|
||||
|
||||
/// Cached schedule update date.
|
||||
///
|
||||
/// Determined by the polytechnic's server.
|
||||
pub last_schedule_update: i64,
|
||||
}
|
||||
|
||||
|
||||
@@ -53,18 +53,18 @@ mod schema {
|
||||
#[schema(as = GetTeacher::Response)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Response {
|
||||
/// Расписание преподавателя
|
||||
/// Teacher's schedule.
|
||||
pub teacher: ScheduleEntry,
|
||||
|
||||
/// Устаревшая переменная
|
||||
/// ## Deprecated variable.
|
||||
///
|
||||
/// По умолчанию возвращается пустой список
|
||||
/// By default, an empty list is returned.
|
||||
#[deprecated = "Will be removed in future versions"]
|
||||
pub updated: Vec<i32>,
|
||||
|
||||
/// Устаревшая переменная
|
||||
/// ## Deprecated variable.
|
||||
///
|
||||
/// По умолчанию начальная дата по Unix
|
||||
/// Defaults to the Unix start date.
|
||||
#[deprecated = "Will be removed in future versions"]
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -84,12 +84,12 @@ mod schema {
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[schema(as = TeacherSchedule::ErrorCode)]
|
||||
pub enum ErrorCode {
|
||||
/// Расписания ещё не получены
|
||||
/// Schedules have not yet been parsed.
|
||||
#[status_code = "actix_web::http::StatusCode::SERVICE_UNAVAILABLE"]
|
||||
#[display("Schedule not parsed yet.")]
|
||||
NoSchedule,
|
||||
|
||||
/// Преподаватель не найден
|
||||
/// Teacher not found.
|
||||
#[status_code = "actix_web::http::StatusCode::NOT_FOUND"]
|
||||
#[display("Required teacher not found.")]
|
||||
NotFound,
|
||||
|
||||
@@ -35,7 +35,7 @@ mod schema {
|
||||
#[derive(Serialize, ToSchema)]
|
||||
#[schema(as = GetTeacherNames::Response)]
|
||||
pub struct Response {
|
||||
/// Список имён преподавателей отсортированный в алфавитном порядке
|
||||
/// List of teacher names sorted alphabetically.
|
||||
#[schema(examples(json!(["Хомченко Н.Е."])))]
|
||||
pub names: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ mod schema {
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct Request {
|
||||
/// Ссылка на расписание
|
||||
/// Schedule link.
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
@@ -92,25 +92,26 @@ mod schema {
|
||||
#[status_code = "actix_web::http::StatusCode::NOT_ACCEPTABLE"]
|
||||
#[schema(as = SetDownloadUrl::ErrorCode)]
|
||||
pub enum ErrorCode {
|
||||
/// Передана ссылка с хостом отличающимся от politehnikum-eng.ru
|
||||
/// Transferred link with host different from politehnikum-eng.ru.
|
||||
#[display("URL with unknown host provided. Provide url with politehnikum-eng.ru host.")]
|
||||
NonWhitelistedHost,
|
||||
|
||||
/// Не удалось получить мета-данные файла
|
||||
/// Failed to retrieve file metadata.
|
||||
#[display("Unable to retrieve metadata from the specified URL.")]
|
||||
FetchFailed,
|
||||
|
||||
/// Не удалось скачать файл
|
||||
/// Failed to download the file.
|
||||
#[display("Unable to retrieve data from the specified URL.")]
|
||||
DownloadFailed,
|
||||
|
||||
/// Ссылка ведёт на устаревшее расписание
|
||||
/// The link leads to an outdated schedule.
|
||||
///
|
||||
/// Под устаревшим расписанием подразумевается расписание, которое было опубликовано раньше, чем уже имеется на данный момент
|
||||
/// An outdated schedule refers to a schedule that was published earlier
|
||||
/// than is currently available.
|
||||
#[display("The schedule is older than it already is.")]
|
||||
OutdatedSchedule,
|
||||
|
||||
/// Не удалось преобразовать расписание
|
||||
/// Failed to parse the schedule.
|
||||
#[display("{}", "_0.display()")]
|
||||
InvalidSchedule(ParseError),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user