feat: Enhance session handling in timetable and UI
- Introduced session types (exams, credits, consultations, coursework defenses) with distinct icons and colors for better visibility in the UI. - Updated PlansScreen, ScheduleScreen, and WeekGrid to display session information appropriately. - Modified CalendarView and PlansView to include session indicators in the calendar and plans. - Enhanced LessonCard and CompactLesson to show session details and adjust styling based on session presence. - Added new SessionMark component for consistent session representation across Android and iOS. - Updated server logic to handle session entries from external documents, ensuring accurate timetable representation. - Improved date parsing to accommodate session-related dates in various formats. - Added tests to verify session handling and date parsing functionality.
This commit is contained in:
@@ -16,6 +16,8 @@ import {
|
||||
freeRooms,
|
||||
examsOf,
|
||||
findGroups,
|
||||
readyIndex,
|
||||
sessionEntriesOf,
|
||||
directoryCalendar,
|
||||
todayIso,
|
||||
} from "./directory.js";
|
||||
@@ -42,8 +44,9 @@ app.use("/api", (_req, res, next) => {
|
||||
// Raised whenever an endpoint is added or changed, so a deployment is easy to verify:
|
||||
// 2 — /api/timetable for the Android client; 3 — its range=semester;
|
||||
// 4 — compression, ETag revalidation, throttled refresh and import limits;
|
||||
// 5 — error codes (`code` beside `error`, see server/errors.js), timetable 304 before any work.
|
||||
const API_VERSION = 5;
|
||||
// 5 — error codes (`code` beside `error`, see server/errors.js), timetable 304 before any work;
|
||||
// 6 — the timetable carries the group's exams and credits from other catalog documents.
|
||||
const API_VERSION = 6;
|
||||
|
||||
// Liveness plus what the server currently reads from the university, without network calls.
|
||||
app.get("/api/health", async (_req, res) => {
|
||||
@@ -118,25 +121,30 @@ app.get("/api/timetable", async (req, res, next) => {
|
||||
const calendar = await directoryCalendar();
|
||||
const range = req.query.range === "semester" ? "semester" : undefined;
|
||||
const today = todayIso();
|
||||
// The group's exams and credits from other documents ("Расписание зачетов"); a server
|
||||
// still building its first index answers without them rather than wait.
|
||||
const idx = readyIndex();
|
||||
// The answer follows only from these: the document's version, the parser and the server
|
||||
// that read it, the week table, the request and the date. An unchanged one comes back
|
||||
// as an empty 304 before the document is opened or a single day is computed.
|
||||
const etag = 'W/"tt-' + createHash("sha1")
|
||||
.update([API_VERSION, PARSER_VERSION, file.id, file.modified, calendar?.updatedAt, group, from, req.query.days, range, today].join("|"))
|
||||
.update([API_VERSION, PARSER_VERSION, file.id, file.modified, calendar?.updatedAt, idx?.builtAt, group, from, req.query.days, range, today].join("|"))
|
||||
.digest("base64url")
|
||||
.slice(0, 22) + '"';
|
||||
res.set("ETag", etag);
|
||||
if (req.fresh) return res.status(304).end();
|
||||
const schedule = await scheduleFor(file);
|
||||
res.json(
|
||||
timetable({
|
||||
file,
|
||||
schedule: await scheduleFor(file),
|
||||
schedule,
|
||||
calendar,
|
||||
group,
|
||||
from,
|
||||
days: req.query.days,
|
||||
range,
|
||||
today,
|
||||
session: sessionEntriesOf(idx, group, file.faculty || schedule.source.faculty, file.id),
|
||||
}),
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user