hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! The registration workflow: taking a seat on a registration-audience |
| 2 | //! event. The reads and the seat-returning delete are |
| 3 | //! [`crate::db::registration`]; the seat itself is [`cap`]'s |
| 4 | //! claim-on-the-event-row. |
| 5 | |
| 6 | use crateDatabase; |
| 7 | use crateClaimed; |
| 8 | use crateregistration; |
| 9 | use crateEventId; |
| 10 | use crateRegistration; |
| 11 | use crateRole; |
| 12 | use crateUserId; |
| 13 | use crateAppError; |
| 14 | |
| 15 | /// Register (idempotently) `user` onto `event`, refusing when a capacity |
| 16 | /// cap is set and every seat is taken. Someone already listed gets their |
| 17 | /// existing row back untouched — a true no-op that never counts against |
| 18 | /// the cap and never rewrites who placed them. The seat is taken by |
| 19 | /// [`cap::claim_live_and_create`] on the event row — an atomic single-record |
| 20 | /// conditional write that reads `audience.capacity` off that same row as it |
| 21 | /// decides, so neither a racing registration nor a concurrent PATCH |
| 22 | /// *lowering* the capacity can over-admit. Bound as a number instead, the |
| 23 | /// snapshot below would admit every request already in flight when the |
| 24 | /// lower cap landed. |
| 25 | /// |
| 26 | /// The seat is claimed on the event row, so the same statement says nothing |
| 27 | /// about the *user* it is for — and a fall to `parent` is the one demotion |
| 28 | /// whose sweep ([`crate::service::user::set_role`]) can miss a seat and |
| 29 | /// leave it unfreeable: `unregister` refuses a non-student target and a |
| 30 | /// parent cannot reach the route at all. So the transaction also claims the |
| 31 | /// holder's own record ([`cap::role_claim`]), which is the key that |
| 32 | /// demotion writes: either the sweep sees this seat, or this write sees the |
| 33 | /// parent and takes it back. |
| 34 | pub async |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | /// Take a user off the list; `Some` iff they held a seat. |
| 75 | pub async |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 |