forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/db/settings.rsClear filter

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-14

🐛 fix: settings CAS compared the new row to itselfAhmet Kaan Gümüş · 4de958f
🐛 fix: settings CAS compared the new row to itself

save_if_unchanged WHERE used $1/$3/… (the write) instead of expected.
Any second real PATCH exhausted retries and 409'd.
✨ feat: compose-stack deploy plus in-tree schema workAhmet Kaan Gümüş · 57fad2c
✨ feat: compose-stack deploy plus in-tree schema work

Production deploy is podman compose (postgres + backend + openobserve)
instead of a systemd binary. CI stays a throwaway postgres sidecar.
Operator credentials live in ~/hezarfen_backend/hezarfen_backend.env
(0600); the deploy never writes that file.

Also lands the working-tree schema/junction and .sqlx updates that were
already sitting next to this change.

2026-09-12

🗃️ feat!: port identity+auth (user, session, profile, badge, settings, builder) to sqlx/PostgresAhmet Kaan Gümüş · 29cdff2
🗃️ feat!: port identity+auth (user, session, profile, badge, settings, builder) to sqlx/Postgres

- db/user: static query_as! row mint (23505 on app_user_username -> 409),
  PagedList listings, position()-based fold search, role cascade as ONE
  tx_with_retry(cascade=true) closure (admin floor = guard on the role write
  itself; class/enrollment counts decrement in the delete CTEs; parent-seat
  sweep frees unfrozen lists via DELETE..USING; board close CAS + strip with
  post-image fan-out rows; appointment bookings cancelled then slots deleted
  under the new SET NULL link); avatar writers return the FOR UPDATE pre-image
- service/user: ADMIN_FLOOR_LOCK deleted (floor rides the UPDATE's WHERE),
  would_orphan_admins deleted; set_role keeps the 404 pre-read
- service/settings: SETTINGS_LOCK, Undo/restore deleted; retire/unretire +
  guarded save ride ONE transaction (stale save aborts via marker and retries);
  retire switch = cap.rs recipe (FOR UPDATE + ON CONFLICT..WHERE count=0);
  messages byte-identical
- db/settings: load/save/save_if_unchanged as static macros; CAS is ONE
  guarded upsert (INSERT arm seeds defaults, ON CONFLICT WHERE
  IS NOT DISTINCT FROM per column)
- db/badge: counter projection off app_user *_total columns; sync keeps the
  runtime N-statement exemption with ON CONFLICT..WHERE earned_at IS NULL
- db/profile: one-row pomodoro aggregate (COALESCE sum, negative floor)
- db/session, db/builder: static macros; builder_session keys now uuid v7
- domain/badge: fields crate-visible for macro construction
- db/page: Param::Texts variant for ANY() text-array binds
- web/users: avatar blob name mints via next_uuid; docs de-Surrealized
- cfg(test) mods left for wave 3 (service/settings tests reference the deleted
  lock machinery; db tests reference init_mem)

SQL semantics probe-verified on a scratch Postgres: CAS arms (insert/match/
stale/NULL), admin floor (demote/refuse/promote), retire switch (insert/
in-use-refused/unchanged/idempotent unretire), cascade CTEs (counts, frozen
list kept, strip post-image, close first-stamp-wins), position() fold,
badge stamp idempotency.

2026-09-11

🧹 chore: split note/session/settings into domain/db/service layersAhmet Kaan Gümüş · efea304
🧹 chore: split note/session/settings into domain/db/service layers

Pilot wave of the three-layer split. All query execution for the three
domains now lives in src/db/{note,session,settings}.rs as free fns taking
db first; web handlers call service::<x>::* only; domain keeps pure types.

- service/settings.rs gains the PATCH workflow (apply) and SETTINGS_LOCK —
  it spans a multi-call pair (retire names, CAS save, restore), so it is a
  service lock, not a db lock. The service takes its own input records
  (SettingsPatch/*Input) so wire DTOs stay in web and list validation keeps
  its original order, including the try_kept grandfathering that needs the
  stored list.
- Note/Session/Settings fields the db layer mints or CAS-binds become
  pub(crate); Settings::record_id becomes pub(crate).
- Unit tests rode with their fns: note delete cascade → db/note, session
  purge → db/session, settings load/save/CAS → db/settings, the whole
  settings edit workflow suite → service/settings.
- Doc links re-pointed (user, class_blueprint, bank_question, exam,
  note_file, tests/regress_roles); NoteId::generate's stale
  'Note::list_for_user' link now names db::note::list_for.
- Known residual for a later wave: web/notes.rs:411 file.delete() is
  note_file-domain persistence (note_file splits in C3).