fix: backfill binaryDecision, fix boolean criterion lookup, add assign buttons
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m9s
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m9s
- Backfilled 166 evaluations' binaryDecision from criterionScoresJson on production DB - Fixed roundEvaluationScores and ai-ranking to look in EvaluationForm.criteriaJson instead of round.configJson for the boolean "Move to the Next Stage?" criterion - Added advanceMode (count/threshold) toggle to round config Advancement Targets - Added "Assign to Jurors" button on Unassigned Projects section and Projects tab bulk bar Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1434,7 +1434,10 @@ export default function RoundDetailPage() {
|
||||
|
||||
{/* ═══════════ PROJECTS TAB ═══════════ */}
|
||||
<TabsContent value="projects" className="space-y-4">
|
||||
<ProjectStatesTable competitionId={competitionId} roundId={roundId} />
|
||||
<ProjectStatesTable competitionId={competitionId} roundId={roundId} onAssignProjects={() => {
|
||||
setActiveTab('assignments')
|
||||
setTimeout(() => setPreviewSheetOpen(true), 100)
|
||||
}} />
|
||||
</TabsContent>
|
||||
|
||||
{/* ═══════════ FILTERING TAB ═══════════ */}
|
||||
@@ -1797,7 +1800,7 @@ export default function RoundDetailPage() {
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<COIReviewSection roundId={roundId} />
|
||||
<RoundUnassignedQueue roundId={roundId} requiredReviews={(config.requiredReviewsPerProject as number) || 3} />
|
||||
<RoundUnassignedQueue roundId={roundId} requiredReviews={(config.requiredReviewsPerProject as number) || 3} onAssignUnassigned={() => setPreviewSheetOpen(true)} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -2157,13 +2160,64 @@ export default function RoundDetailPage() {
|
||||
|
||||
<div className="border-t mt-2 pt-4 px-4 pb-2 bg-[#053d57]/[0.03] rounded-b-lg -mx-6 -mb-6 p-6">
|
||||
<Label className="text-sm font-medium">Advancement Targets</Label>
|
||||
<p className="text-xs text-muted-foreground mb-3">
|
||||
How to determine which projects advance from this round
|
||||
</p>
|
||||
|
||||
{/* Mode toggle */}
|
||||
<div className="flex gap-2 mb-4">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={(config.advanceMode as string) === 'threshold' ? 'outline' : 'default'}
|
||||
className="h-8 text-xs"
|
||||
onClick={() => handleConfigChange({ ...config, advanceMode: 'count' })}
|
||||
>
|
||||
Fixed Count
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={(config.advanceMode as string) === 'threshold' ? 'default' : 'outline'}
|
||||
className="h-8 text-xs"
|
||||
onClick={() => handleConfigChange({ ...config, advanceMode: 'threshold' })}
|
||||
>
|
||||
Score Threshold
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{(config.advanceMode as string) === 'threshold' ? (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="advance-threshold" className="text-xs text-muted-foreground">
|
||||
Minimum Average Score to Advance
|
||||
</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
All projects scoring at or above this threshold will advance (both categories)
|
||||
</p>
|
||||
<Input
|
||||
id="advance-threshold"
|
||||
type="number"
|
||||
min={0}
|
||||
max={10}
|
||||
step={0.1}
|
||||
className="h-9 w-32"
|
||||
placeholder="e.g. 6.5"
|
||||
value={(config.advanceScoreThreshold as number) ?? ''}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value ? parseFloat(e.target.value) : undefined
|
||||
handleConfigChange({ ...config, advanceScoreThreshold: val })
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{isEvaluation && !(config.startupAdvanceCount as number) && !(config.conceptAdvanceCount as number) && (
|
||||
<div className="mt-2 mb-1 rounded-md border border-amber-200 bg-amber-50 px-3 py-2">
|
||||
<div className="mb-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2">
|
||||
<p className="text-xs text-amber-700">Advancement targets not configured — all passed projects will be eligible to advance.</p>
|
||||
</div>
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground mb-3">
|
||||
Target number of projects per category to advance from this round
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
Target number of projects per category to advance
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
@@ -2201,6 +2255,8 @@ export default function RoundDetailPage() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
'use client'
|
||||
|
||||
import { Users } from 'lucide-react'
|
||||
import { trpc } from '@/lib/trpc/client'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
export type RoundUnassignedQueueProps = {
|
||||
roundId: string
|
||||
requiredReviews?: number
|
||||
onAssignUnassigned?: () => void
|
||||
}
|
||||
|
||||
export function RoundUnassignedQueue({ roundId, requiredReviews = 3 }: RoundUnassignedQueueProps) {
|
||||
export function RoundUnassignedQueue({ roundId, requiredReviews = 3, onAssignUnassigned }: RoundUnassignedQueueProps) {
|
||||
const { data: unassigned, isLoading } = trpc.roundAssignment.unassignedQueue.useQuery(
|
||||
{ roundId, requiredReviews },
|
||||
{ refetchInterval: 15_000 },
|
||||
@@ -18,10 +21,18 @@ export function RoundUnassignedQueue({ roundId, requiredReviews = 3 }: RoundUnas
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm font-medium">Unassigned Projects</p>
|
||||
<p className="text-xs text-muted-foreground">Projects with fewer than {requiredReviews} jury assignments</p>
|
||||
</div>
|
||||
{unassigned && unassigned.length > 0 && onAssignUnassigned && (
|
||||
<Button size="sm" variant="outline" onClick={onAssignUnassigned}>
|
||||
<Users className="h-3.5 w-3.5 mr-1.5" />
|
||||
Assign to Jurors
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
{isLoading ? (
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -59,6 +59,7 @@ import {
|
||||
Search,
|
||||
ExternalLink,
|
||||
Sparkles,
|
||||
Users,
|
||||
} from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import type { Route } from 'next'
|
||||
@@ -78,9 +79,10 @@ const stateConfig: Record<ProjectState, { label: string; color: string; icon: Re
|
||||
type ProjectStatesTableProps = {
|
||||
competitionId: string
|
||||
roundId: string
|
||||
onAssignProjects?: (projectIds: string[]) => void
|
||||
}
|
||||
|
||||
export function ProjectStatesTable({ competitionId, roundId }: ProjectStatesTableProps) {
|
||||
export function ProjectStatesTable({ competitionId, roundId, onAssignProjects }: ProjectStatesTableProps) {
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set())
|
||||
const [stateFilter, setStateFilter] = useState<string>('ALL')
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
@@ -321,6 +323,16 @@ export function ProjectStatesTable({ competitionId, roundId }: ProjectStatesTabl
|
||||
<ArrowRight className="h-3.5 w-3.5 mr-1.5" />
|
||||
Change State
|
||||
</Button>
|
||||
{onAssignProjects && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => onAssignProjects(Array.from(selectedIds))}
|
||||
>
|
||||
<Users className="h-3.5 w-3.5 mr-1.5" />
|
||||
Assign to Jurors
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
|
||||
@@ -408,18 +408,15 @@ export const rankingRouter = router({
|
||||
roundEvaluationScores: adminProcedure
|
||||
.input(z.object({ roundId: z.string() }))
|
||||
.query(async ({ ctx, input }) => {
|
||||
// Fetch the round config to find the boolean criterion ID (legacy fallback)
|
||||
const round = await ctx.prisma.round.findUniqueOrThrow({
|
||||
where: { id: input.roundId },
|
||||
select: { configJson: true },
|
||||
// Find the boolean criterion ID from the EvaluationForm (not round configJson)
|
||||
const evalForm = await ctx.prisma.evaluationForm.findFirst({
|
||||
where: { roundId: input.roundId, isActive: true },
|
||||
select: { criteriaJson: true },
|
||||
})
|
||||
const roundConfig = round.configJson as Record<string, unknown> | null
|
||||
const criteria = (roundConfig?.criteria ?? roundConfig?.evaluationCriteria ?? []) as Array<{
|
||||
id: string
|
||||
label: string
|
||||
type?: string
|
||||
}>
|
||||
const boolCriterionId = criteria.find(
|
||||
const formCriteria = (evalForm?.criteriaJson as Array<{
|
||||
id: string; label: string; type?: string
|
||||
}> | null) ?? []
|
||||
const boolCriterionId = formCriteria.find(
|
||||
(c) => c.type === 'boolean' && c.label?.toLowerCase().includes('move to the next stage'),
|
||||
)?.id ?? null
|
||||
|
||||
|
||||
@@ -247,17 +247,11 @@ function anonymizeProjectsForRanking(
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the boolean criterion ID for "Move to the Next Stage?" from round config.
|
||||
* Returns null if no such criterion exists.
|
||||
* Find the boolean criterion ID for "Move to the Next Stage?" from criteria definitions.
|
||||
* Accepts criteria from EvaluationForm.criteriaJson (preferred) or round configJson (legacy).
|
||||
*/
|
||||
function findBooleanCriterionId(roundConfig: Record<string, unknown> | null): string | null {
|
||||
if (!roundConfig) return null
|
||||
const criteria = (roundConfig.criteria ?? roundConfig.evaluationCriteria ?? []) as Array<{
|
||||
id: string
|
||||
label: string
|
||||
type?: string
|
||||
}>
|
||||
const boolCriterion = criteria.find(
|
||||
function findBooleanCriterionId(criterionDefs: Array<{ id: string; label: string; type?: string }>): string | null {
|
||||
const boolCriterion = criterionDefs.find(
|
||||
(c) => c.type === 'boolean' && c.label?.toLowerCase().includes('move to the next stage'),
|
||||
)
|
||||
return boolCriterion?.id ?? null
|
||||
@@ -593,7 +587,6 @@ export async function fetchAndRankCategory(
|
||||
])
|
||||
|
||||
const roundConfig = round.configJson as Record<string, unknown> | null
|
||||
const boolCriterionId = findBooleanCriterionId(roundConfig)
|
||||
|
||||
// Parse evaluation config for criteria weights
|
||||
const evalConfig = roundConfig as EvaluationConfig | null
|
||||
@@ -603,6 +596,7 @@ export async function fetchAndRankCategory(
|
||||
const criterionDefs: CriterionDef[] = evalForm?.criteriaJson
|
||||
? (evalForm.criteriaJson as unknown as CriterionDef[])
|
||||
: []
|
||||
const boolCriterionId = findBooleanCriterionId(criterionDefs)
|
||||
const numericCriterionIds = new Set(
|
||||
criterionDefs.filter((d) => !d.type || d.type === 'numeric').map((d) => d.id),
|
||||
)
|
||||
|
||||
@@ -12,6 +12,8 @@ import type { RoundType, AwardEligibilityMode, AwardScoringMode, AwardStatus } f
|
||||
const generalSettingsFields = {
|
||||
startupAdvanceCount: z.number().int().nonnegative().optional(),
|
||||
conceptAdvanceCount: z.number().int().nonnegative().optional(),
|
||||
advanceMode: z.enum(['count', 'threshold']).default('count'),
|
||||
advanceScoreThreshold: z.number().min(0).max(10).optional(),
|
||||
notifyOnEntry: z.boolean().default(false),
|
||||
notifyOnAdvance: z.boolean().default(false),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user