feat: complete ShiftCraft — AI-powered shift scheduling SaaS
Complete implementation including:
- Landing page with hero, features, how-it-works, pricing
- Employee management (CRUD with soft delete)
- AI constraint parser (Anthropic Claude API)
- German labor law templates (ArbZG §3, §5, §9)
- HiGHS ILP solver for optimal fair schedules
- Schedule calendar result view (employee × date grid)
- Shift framework configuration (periods + shifts)
- Subscription tiers: Free / Pro / Business
- PocketBase setup script with collection creation + seed data
- .env.example with all required variables documented
Pages: employees, constraints (list/new/templates), schedules (list/new/[id]),
settings (organization/shifts/billing), dashboard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
38
server/utils/solver/resultParser.ts
Normal file
38
server/utils/solver/resultParser.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { SolveInput, ShiftAssignment } from '~/shared/types/schedule'
|
||||
import { getDaysInRange } from '~/app/utils/dateHelpers'
|
||||
|
||||
export function parseAssignments(result: Record<string, unknown>, input: SolveInput): ShiftAssignment[] {
|
||||
const { employees, framework, period_start, period_end } = input
|
||||
const days = getDaysInRange(period_start, period_end)
|
||||
const E = employees.length
|
||||
const S = framework.shifts.length
|
||||
const D = days.length
|
||||
const assignments: ShiftAssignment[] = []
|
||||
|
||||
const solution = result.Columns as Record<string, { Primal: number }>
|
||||
|
||||
for (let e = 0; e < E; e++) {
|
||||
for (let s = 0; s < S; s++) {
|
||||
for (let d = 0; d < D; d++) {
|
||||
const varName = `x_${e}_${s}_${d}`
|
||||
const value = solution[varName]?.Primal ?? 0
|
||||
if (value > 0.5) {
|
||||
const shift = framework.shifts[s]
|
||||
const period = framework.periods.find(p => p.id === shift.period_id)
|
||||
assignments.push({
|
||||
employee_id: employees[e].id,
|
||||
employee_name: employees[e].name,
|
||||
shift_id: shift.id,
|
||||
shift_name: shift.name,
|
||||
period_id: shift.period_id,
|
||||
date: days[d],
|
||||
start_time: period?.start_time ?? '00:00',
|
||||
end_time: period?.end_time ?? '00:00',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return assignments
|
||||
}
|
||||
Reference in New Issue
Block a user