knapsack scheduling algorithm

This commit is contained in:
2026-07-12 14:19:58 -04:00
parent 031da48ddd
commit 9e100d60d0
56 changed files with 1936 additions and 1286 deletions
+39 -8
View File
@@ -2,14 +2,24 @@ import ShiftSlot from './ShiftSlot'
const DAY_NAMES = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
export default function DayColumn({ date, isToday, activeShifts = new Set(), shifts = {}, showShift2 = false }) {
export default function DayColumn({
date,
isToday,
activeShifts = new Set(),
shifts = {},
showShift2 = false,
windowLookup = new Map(),
onWindowSelect,
}) {
const dayName = DAY_NAMES[date.getDay()]
const dayNum = date.getDate()
const isWeekend = date.getDay() === 0 || date.getDay() === 6
const hasActive = activeShifts.size > 0
const dateKey = date.toISOString().slice(0, 10)
// Shift 2 is visible if: weekend, holiday (showShift2), or daytime testing on
const shift2Visible = isWeekend || showShift2
function getWindowForShift(shiftIndex) {
return windowLookup.get(`${dateKey}::shift${shiftIndex}`) ?? null
}
const shift2Visible = showShift2 || shifts.shift2.length > 0 || Boolean(getWindowForShift(2))
return (
<div className="flex flex-col min-w-0 flex-1 rounded-lg border border-gray-700 bg-gray-800/40">
@@ -29,9 +39,30 @@ export default function DayColumn({ date, isToday, activeShifts = new Set(), shi
{/* Shifts */}
<div className="flex flex-col flex-1 px-0.5 py-1">
<ShiftSlot label="12AM9AM" tests={shifts.shift1} visible={true} active={activeShifts.has(1)} />
<ShiftSlot label="9AM5PM" tests={shifts.shift2} visible={true} active={activeShifts.has(2)} />
<ShiftSlot label="5PM12AM" tests={shifts.shift3} visible={true} active={activeShifts.has(3)} />
<ShiftSlot
label="12AM9AM"
tests={shifts.shift1}
visible={true}
active={activeShifts.has(1)}
windowDetails={getWindowForShift(1)}
onWindowSelect={onWindowSelect}
/>
<ShiftSlot
label="9AM5PM"
tests={shifts.shift2}
visible={true}
active={activeShifts.has(2)}
windowDetails={getWindowForShift(2)}
onWindowSelect={onWindowSelect}
/>
<ShiftSlot
label="5PM12AM"
tests={shifts.shift3}
visible={true}
active={activeShifts.has(3)}
windowDetails={getWindowForShift(3)}
onWindowSelect={onWindowSelect}
/>
</div>
</div>
)