Skip to main content

Module service

Module service 

Source
Expand description

The draft-entry editor’s service layer: cap math, candidate pools, and the page / slot / save operations the handler and templates consume.

Structs§

CapState
A draft’s cap position: how many slots are filled, what is left under the cap, and the average left per open slot.
EditorPage
The editor page: cap state, the nine rows, and whether the slate is read-only.
EditorSlotRow
One of the editor’s nine slot rows: what fills the slot and how it prices.
SlotChoice
One candidate for a slot’s pick list, with its price and pace.

Functions§

choices
The candidate list for one slot, salary-descending from the snapshot. Omits players already picked into another slot; the current occupant of slot appears marked is_picked. Defense choices carry the team abbr as the value key.
clear_slot
Empty a slot. An absent draft is created then cleared (net no-op). Refuses on a locked slate.
discard
Delete the draft row, abandoning the in-progress lineup. Never refused: there is no committed data to protect.
editor_page
Open (or resume) the draft and assemble the editor page. NotFound when the slate is not published with salaried players.
remaining_and_per_open
Remaining budget and the per-open-slot average. Negative remaining = over the cap.
save
Commit the draft as a real entry: upsert the entries row, replace its nine entry_slots, and delete the draft row. Refuses when the lineup is incomplete or over the salary cap.
set_slot
Place (or replace) a pick in a slot. Rejects an invalid pick (see [validate_pick]) and refuses on a locked slate.