Fix per-juror assignment caps: read correct field + inline edit UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m50s

- Fix bug: AI assignment router read non-existent `(m as any).maxAssignments`
  instead of the actual schema field `m.maxAssignmentsOverride`
- Wire `jurorLimits` record into AI assignment constraints so per-juror
  caps are respected during both AI scoring and algorithmic assignment
- Add inline editable cap in jury members table (click to edit, blur/enter
  to save, empty = no cap / use group default)
- Add inline editable cap badges on round page member list so admins can
  set caps right from the assignment workflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-18 18:23:54 +01:00
parent 735b841f4a
commit 6838b01724
3 changed files with 177 additions and 4 deletions

View File

@@ -101,7 +101,7 @@ export const roundAssignmentRouter = router({
expertiseTags: (m.user.expertiseTags as string[]) ?? [],
bio: m.user.bio as string | null,
country: m.user.country as string | null,
maxAssignments: (m as any).maxAssignments as number | null ?? null,
maxAssignments: m.maxAssignmentsOverride ?? null,
_count: {
assignments: existingAssignments.filter((a) => a.userId === m.user.id).length,
},
@@ -142,9 +142,18 @@ export const roundAssignmentRouter = router({
const calculatedMax = Math.ceil(totalNeeded / jurorCount) + 2
const maxPerJuror = configuredMax ?? calculatedMax
// Build per-juror cap overrides
const jurorLimits: Record<string, number> = {}
for (const m of round.juryGroup.members) {
if (m.maxAssignmentsOverride != null) {
jurorLimits[m.user.id] = m.maxAssignmentsOverride
}
}
const constraints = {
requiredReviewsPerProject: input.requiredReviews,
maxAssignmentsPerJuror: maxPerJuror,
jurorLimits,
existingAssignments: existingAssignments.map((a) => ({
jurorId: a.userId,
projectId: a.projectId,