forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/service/course_session.rsClear filter

2026-09-25

✨ feat(api): server-side filters on the list doorsAhmet Kaan Gümüş · d8dad92
✨ feat(api): server-side filters on the list doors

A caller no longer has to download a capped collection and narrow it
in the client:

- events, exams: the WindowParams pair is SQL (no whole-table load)
  and gains starts_before/ends_before, so a past/completed view is
  expressible
- sessions: starts_after/starts_before, half-open months
- homework: due_after/due_before (the open/past tabs), class_course
- meals menus: slot (was a post-page JS filter — page counts lied)
- users (admin): roles= comma set; courses: kind, q, taught
- appointments + slots: teacher (or me), starts_after/starts_before,
  status
- pomodoro log: from/to, with the focus total summed in SQL
- messages and boards: q (folded literal substring)
- pool questions: ?status= is a WHERE, not a post-filter
- bank/course-notes id filters: garbage is a 400 naming the field,
  not an empty page

Absent params return today's response byte-shape; page and count
share one WHERE.

2026-09-24

🧪 test(schedule): the materializer, the holiday calendar and section lists end to endAhmet Kaan Gümüş · aa7132a
🧪 test(schedule): the materializer, the holiday calendar and section lists end to end

`tests/regress_schedule.rs`: 20 tests over the new surface — holiday CRUD with
its role gates and the overlap window filter, dry-run vs apply vs idempotent
re-apply, the holiday skip, both coded refusals, the range and candidate caps,
`session_time_taken` on a hand-made lesson at a generated instant, and the
per-section course lists (catalogue row, `/courses/me`, the profile block,
reach filtering). The four generated-lesson tests assert the slot's own
weekday, the +180 school zone, the topic fallback chain and the instance's
first assigned teacher.

One stale pin moved in `tests/integration.rs`
(`session_crud_follows_course_management`): it created two lessons of one
section at the same instant, a premise the new UNIQUE (class_course,
starts_at) wall outlaws — the second lesson now gets its own instant and the
assertions about the manager's rights are unchanged. `tests/regress_profile.rs`
and `tests/persistence.rs` needed no change.

README's generated `## Endpoints` table picks up the five `/holidays` routes
and the materialize route.
Merge branch 'lane/sections'Ahmet Kaan Gümüş · 721daa1
Merge branch 'lane/sections'

# Conflicts:
#	src/service/course_session.rs
✨ feat(holidays): the non-teaching calendar over the API and the materialize routeAhmet Kaan Gümüş · 3547dc5
✨ feat(holidays): the non-teaching calendar over the API and the materialize route

`src/web/holidays.rs`: five routes (paged overlap-filtered `GET /holidays`,
`GET /holidays/{id}` for any session, manager-gated `POST`/`PATCH`/`DELETE`),
nested ungated beside `/terms` and tagged in the spec. `HolidayLimits` and the
weekly-plan materialize caps join `GET /limits`, and `max_course_sections` is
published with them.

`POST /instances/{id}/weekly-plan/materialize` turns a section's resolved plan
into dated lessons over a range: dry run by default, the same call with
`apply: true` commits, holidays and already-scheduled starts are reported as
skipped, and the response reuses `SessionResponse`. Slot DTOs carry the new
optional topic.

Also closes a wave-1 defect: `service::course_session::materialize` captured
`&PgPool`/`&ClassCourse` in its `tx_with_retry` closure, so its future was not
Send and no route could await it — now owned captures.
✨ feat(courses): per-section course lists behind the catalogue rowAhmet Kaan Gümüş · 6ecaebc
✨ feat(courses): per-section course lists behind the catalogue row

`CourseSectionRef` and `CourseResponse.sections`: every catalogue row now
carries its sections (instance id, resolved title, class, grade level, hours,
teachers, roster size), truncated to `MAX_COURSE_SECTIONS` while
`class_course_count` keeps the untruncated total. `list_courses`/`get_course`
populate it through one batched builder — seven statements per page, nothing
per row — and a non-manager sees only the sections they reach.

`GET /courses/me` and the profile course block switch from catalogue rows to
one row per section with the section's resolved title. Reach is the union of
the class-roster/homeroom/taught set and the user's own instance enrollments,
so a hand-placed enrollment keeps appearing exactly as it did before.
✨ feat(schedule): holiday calendar, slot topics, and the weekly-plan materializer coreAhmet Kaan Gümüş · 7c481f7
✨ feat(schedule): holiday calendar, slot topics, and the weekly-plan materializer core

Schema (migrations/school/20260924000001_holidays_and_materialize.sql): a
school-wide `holiday` table over instant ranges, an optional `topic` on both
weekly-plan slot tables, and UNIQUE (class_course, starts_at) on
course_session so two lessons of one section cannot start together.

Domain: `holiday` (name/kind/range newtypes, inclusive `overlaps`) and
`calendar` (the school-zone day math hoisted out of web/attendance, which now
imports it). `WeeklySlot` carries an optional topic; `overlaps` is unchanged.

Db: `holiday` CRUD + overlap-paged list + the materializer's unpaged read;
`course_session::insert_many` (one unnest INSERT .. ON CONFLICT DO NOTHING
RETURNING, so the reported rows are the rows actually inserted) plus
`existing_starts`; a duplicate start on the single-session route now answers
409 session_time_taken instead of a 500.

Service: `holiday` pass-throughs and `course_session::materialize` — one
transaction, archived-year wall, row lock on the instance, refusals coded
instance_has_no_weekly_plan / instance_has_no_teacher, a range cap of 366 days
and a candidate cap of 500, holidays and already-scheduled starts skipped and
counted, nothing ever deleted. Dry run is side-effect free.

The HTTP surface, per-section course lists, and the integration suite follow in
later commits.

2026-09-16

✨ feat: the class×course instance is the academic anchor (K-12 remodel)Ahmet Kaan Gümüş · ae84034
✨ feat: the class×course instance is the academic anchor (K-12 remodel)

`course` was a school-wide singleton: enrollment, exams, sessions,
roll-call and homework all keyed on it, so two class sections teaching the same
course shared one roster, one exam set and one timetable. This moves the
academic anchor to `class_course` — the per-class instance — and rebuilds
the academic model around Turkish K-12.

Schema (migrations/school/20260916000001_k12_remodel.sql): `class_course`
becomes an instance (ders_saati, counts_toward_karne, enrollment_count,
class_course_teacher); enrollment re-keys to (class_course, app_user);
exam carries class_course + term (+ exam_audience for shared exams);
course_session / session_attendance / homework re-key; `class_member` is a
soft-leave history table (uuid PK, joined_at/left_at, partial unique index
on the live stint); `academic_year` sits above `term`; `class_group` links
a year, not a term; new `course_membership` (clubs/study), `karne_snapshot`;
settings gain branches/excuse_kinds/absence limits/timezone; profile gains
branch. Drops/recreates the identity-changing tables (pre-customer; the
migration resets every counter on a kept table that pointed at a dropped
one).

Layers: domain/db/service/web rewritten to the instance seam, with
`ensure_instance_teacher` gating instance writes (D10), the report card computed per
instance and weighted by ders_saati, an absence report, `/instances`
and `/academic-years` nests, and `/classes/{id}/instances`. Capacity and
the seat-claim 409 are gone; detach sweeps the whole instance subtree and
unlinks its blob keys.

Gates: cargo check --all-targets, SQLX_OFFLINE check (cache regenerated),
doc_sync, spec_bounds, limits_completeness, clippy -D warnings all green;
cargo nextest run 1370/1370.

2026-09-11

🧹 chore: split course_session into domain/db/service layersAhmet Kaan Gümüş · 0ddaa5d
🧹 chore: split course_session into domain/db/service layers

domain/course_session.rs keeps the pure surface: CourseSessionId (its ULID
mint stays per the monotonic_id precedent), SessionTopic, the entity with
pub(crate) fields, getters, and the topic-bound validation test.

db/course_session.rs takes the query executors whole: create (the
cap::touch_and_create claim that bumps the course row in the same
transaction), read, list_for_course, the field-scoped update, and the
cascading delete transaction; the orphan-race persistence test rides along.

service/course_session.rs takes resolve_session_teacher out of the web
layer — the scheduling role floor (a student cannot teach a lesson) —
plus the thin doors the web layer now calls instead of the removed
inherent methods. No locks: course_session never held one; the range
guard rides inside the UPDATE's WHERE.

web/sessions.rs and web/courses.rs re-point every CourseSession call and
the shared resolve_session_teacher import to service::course_session;
call sites in domain/session_attendance.rs (incl. tests) and doc links in
domain/event.rs go to db::course_session. tests/ import fixes only.