Competition/Round architecture: full platform rewrite (Phases 1-9)
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s
Replace Pipeline/Stage system with Competition/Round architecture. New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy, ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow. New services: round-engine, round-assignment, deliberation, result-lock, submission-manager, competition-context, ai-prompt-guard. Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with structured prompts, retry logic, and injection detection. All legacy pipeline/stage code removed. 4 new migrations + seed aligned. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -60,23 +60,19 @@ async function JuryDashboardContent() {
|
||||
country: true,
|
||||
},
|
||||
},
|
||||
stage: {
|
||||
round: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
status: true,
|
||||
windowOpenAt: true,
|
||||
windowCloseAt: true,
|
||||
track: {
|
||||
competition: {
|
||||
select: {
|
||||
pipeline: {
|
||||
program: {
|
||||
select: {
|
||||
program: {
|
||||
select: {
|
||||
name: true,
|
||||
year: true,
|
||||
},
|
||||
},
|
||||
name: true,
|
||||
year: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -96,7 +92,7 @@ async function JuryDashboardContent() {
|
||||
},
|
||||
},
|
||||
orderBy: [
|
||||
{ stage: { windowCloseAt: 'asc' } },
|
||||
{ round: { windowCloseAt: 'asc' } },
|
||||
{ createdAt: 'asc' },
|
||||
],
|
||||
}),
|
||||
@@ -106,7 +102,7 @@ async function JuryDashboardContent() {
|
||||
extendedUntil: { gte: new Date() },
|
||||
},
|
||||
select: {
|
||||
stageId: true,
|
||||
roundId: true,
|
||||
extendedUntil: true,
|
||||
},
|
||||
}),
|
||||
@@ -126,49 +122,49 @@ async function JuryDashboardContent() {
|
||||
const completionRate =
|
||||
totalAssignments > 0 ? (completedAssignments / totalAssignments) * 100 : 0
|
||||
|
||||
// Group assignments by stage
|
||||
const assignmentsByStage = assignments.reduce(
|
||||
// Group assignments by round
|
||||
const assignmentsByRound = assignments.reduce(
|
||||
(acc, assignment) => {
|
||||
const stageId = assignment.stage.id
|
||||
if (!acc[stageId]) {
|
||||
acc[stageId] = {
|
||||
stage: assignment.stage,
|
||||
const roundId = assignment.round.id
|
||||
if (!acc[roundId]) {
|
||||
acc[roundId] = {
|
||||
round: assignment.round,
|
||||
assignments: [],
|
||||
}
|
||||
}
|
||||
acc[stageId].assignments.push(assignment)
|
||||
acc[roundId].assignments.push(assignment)
|
||||
return acc
|
||||
},
|
||||
{} as Record<string, { stage: (typeof assignments)[0]['stage']; assignments: typeof assignments }>
|
||||
{} as Record<string, { round: (typeof assignments)[0]['round']; assignments: typeof assignments }>
|
||||
)
|
||||
|
||||
const graceByStage = new Map<string, Date>()
|
||||
const graceByRound = new Map<string, Date>()
|
||||
for (const gp of gracePeriods) {
|
||||
const existing = graceByStage.get(gp.stageId)
|
||||
const existing = graceByRound.get(gp.roundId)
|
||||
if (!existing || gp.extendedUntil > existing) {
|
||||
graceByStage.set(gp.stageId, gp.extendedUntil)
|
||||
graceByRound.set(gp.roundId, gp.extendedUntil)
|
||||
}
|
||||
}
|
||||
|
||||
// Active stages (voting window open)
|
||||
// Active rounds (voting window open)
|
||||
const now = new Date()
|
||||
const activeStages = Object.values(assignmentsByStage).filter(
|
||||
({ stage }) =>
|
||||
stage.status === 'STAGE_ACTIVE' &&
|
||||
stage.windowOpenAt &&
|
||||
stage.windowCloseAt &&
|
||||
new Date(stage.windowOpenAt) <= now &&
|
||||
new Date(stage.windowCloseAt) >= now
|
||||
const activeRounds = Object.values(assignmentsByRound).filter(
|
||||
({ round }) =>
|
||||
round.status === 'ROUND_ACTIVE' &&
|
||||
round.windowOpenAt &&
|
||||
round.windowCloseAt &&
|
||||
new Date(round.windowOpenAt) <= now &&
|
||||
new Date(round.windowCloseAt) >= now
|
||||
)
|
||||
|
||||
// Find next unevaluated assignment in an active stage
|
||||
// Find next unevaluated assignment in an active round
|
||||
const nextUnevaluated = assignments.find((a) => {
|
||||
const isActive =
|
||||
a.stage.status === 'STAGE_ACTIVE' &&
|
||||
a.stage.windowOpenAt &&
|
||||
a.stage.windowCloseAt &&
|
||||
new Date(a.stage.windowOpenAt) <= now &&
|
||||
new Date(a.stage.windowCloseAt) >= now
|
||||
a.round.status === 'ROUND_ACTIVE' &&
|
||||
a.round.windowOpenAt &&
|
||||
a.round.windowCloseAt &&
|
||||
new Date(a.round.windowOpenAt) <= now &&
|
||||
new Date(a.round.windowCloseAt) >= now
|
||||
const isIncomplete = !a.evaluation || a.evaluation.status === 'NOT_STARTED' || a.evaluation.status === 'DRAFT'
|
||||
return isActive && isIncomplete
|
||||
})
|
||||
@@ -176,14 +172,14 @@ async function JuryDashboardContent() {
|
||||
// Recent assignments for the quick list (latest 5)
|
||||
const recentAssignments = assignments.slice(0, 6)
|
||||
|
||||
// Get active stage remaining count
|
||||
// Get active round remaining count
|
||||
const activeRemaining = assignments.filter((a) => {
|
||||
const isActive =
|
||||
a.stage.status === 'STAGE_ACTIVE' &&
|
||||
a.stage.windowOpenAt &&
|
||||
a.stage.windowCloseAt &&
|
||||
new Date(a.stage.windowOpenAt) <= now &&
|
||||
new Date(a.stage.windowCloseAt) >= now
|
||||
a.round.status === 'ROUND_ACTIVE' &&
|
||||
a.round.windowOpenAt &&
|
||||
a.round.windowCloseAt &&
|
||||
new Date(a.round.windowOpenAt) <= now &&
|
||||
new Date(a.round.windowCloseAt) >= now
|
||||
const isIncomplete = !a.evaluation || a.evaluation.status !== 'SUBMITTED'
|
||||
return isActive && isIncomplete
|
||||
}).length
|
||||
@@ -241,7 +237,7 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
<div className="grid gap-3 sm:grid-cols-2 max-w-md mx-auto">
|
||||
<Link
|
||||
href="/jury/stages"
|
||||
href="/jury/competitions"
|
||||
className="group flex items-center gap-3 rounded-xl border border-border/60 p-3 transition-all duration-200 hover:border-brand-blue/30 hover:bg-brand-blue/5 hover:-translate-y-0.5 hover:shadow-md dark:hover:border-brand-teal/30 dark:hover:bg-brand-teal/5"
|
||||
>
|
||||
<div className="rounded-lg bg-blue-50 p-2 transition-colors group-hover:bg-blue-100 dark:bg-blue-950/40">
|
||||
@@ -253,7 +249,7 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
</Link>
|
||||
<Link
|
||||
href="/jury/stages"
|
||||
href="/jury/competitions"
|
||||
className="group flex items-center gap-3 rounded-xl border border-border/60 p-3 transition-all duration-200 hover:border-brand-teal/30 hover:bg-brand-teal/5 hover:-translate-y-0.5 hover:shadow-md"
|
||||
>
|
||||
<div className="rounded-lg bg-teal-50 p-2 transition-colors group-hover:bg-teal-100 dark:bg-teal-950/40">
|
||||
@@ -293,7 +289,7 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
</div>
|
||||
<Button asChild size="lg" className="bg-brand-blue hover:bg-brand-blue-light shadow-md">
|
||||
<Link href={`/jury/stages/${nextUnevaluated.stage.id}/projects/${nextUnevaluated.project.id}/evaluate`}>
|
||||
<Link href={`/jury/competitions/${nextUnevaluated.round.id}/projects/${nextUnevaluated.project.id}/evaluate`}>
|
||||
{nextUnevaluated.evaluation?.status === 'DRAFT' ? 'Continue Evaluation' : 'Start Evaluation'}
|
||||
<ArrowRight className="ml-2 h-4 w-4" />
|
||||
</Link>
|
||||
@@ -363,7 +359,7 @@ async function JuryDashboardContent() {
|
||||
<CardTitle className="text-lg">My Assignments</CardTitle>
|
||||
</div>
|
||||
<Button variant="ghost" size="sm" asChild className="text-brand-teal hover:text-brand-blue">
|
||||
<Link href="/jury/stages">
|
||||
<Link href="/jury/competitions">
|
||||
View all
|
||||
<ArrowRight className="ml-1 h-3 w-3" />
|
||||
</Link>
|
||||
@@ -378,11 +374,11 @@ async function JuryDashboardContent() {
|
||||
const isCompleted = evaluation?.status === 'SUBMITTED'
|
||||
const isDraft = evaluation?.status === 'DRAFT'
|
||||
const isVotingOpen =
|
||||
assignment.stage.status === 'STAGE_ACTIVE' &&
|
||||
assignment.stage.windowOpenAt &&
|
||||
assignment.stage.windowCloseAt &&
|
||||
new Date(assignment.stage.windowOpenAt) <= now &&
|
||||
new Date(assignment.stage.windowCloseAt) >= now
|
||||
assignment.round.status === 'ROUND_ACTIVE' &&
|
||||
assignment.round.windowOpenAt &&
|
||||
assignment.round.windowCloseAt &&
|
||||
new Date(assignment.round.windowOpenAt) <= now &&
|
||||
new Date(assignment.round.windowCloseAt) >= now
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -394,7 +390,7 @@ async function JuryDashboardContent() {
|
||||
)}
|
||||
>
|
||||
<Link
|
||||
href={`/jury/stages/${assignment.stage.id}/projects/${assignment.project.id}`}
|
||||
href={`/jury/competitions/${assignment.round.id}/projects/${assignment.project.id}`}
|
||||
className="flex-1 min-w-0 group"
|
||||
>
|
||||
<p className="text-sm font-medium truncate group-hover:text-brand-blue dark:group-hover:text-brand-teal transition-colors">
|
||||
@@ -405,7 +401,7 @@ async function JuryDashboardContent() {
|
||||
{assignment.project.teamName}
|
||||
</span>
|
||||
<Badge variant="secondary" className="text-[10px] px-1.5 py-0 bg-brand-blue/5 text-brand-blue/80 dark:bg-brand-teal/10 dark:text-brand-teal/80 border-0">
|
||||
{assignment.stage.name}
|
||||
{assignment.round.name}
|
||||
</Badge>
|
||||
</div>
|
||||
</Link>
|
||||
@@ -425,19 +421,19 @@ async function JuryDashboardContent() {
|
||||
)}
|
||||
{isCompleted ? (
|
||||
<Button variant="ghost" size="sm" asChild className="h-7 px-2">
|
||||
<Link href={`/jury/stages/${assignment.stage.id}/projects/${assignment.project.id}/evaluation`}>
|
||||
<Link href={`/jury/competitions/${assignment.round.id}/projects/${assignment.project.id}/evaluate`}>
|
||||
View
|
||||
</Link>
|
||||
</Button>
|
||||
) : isVotingOpen ? (
|
||||
<Button size="sm" asChild className="h-7 px-3 bg-brand-blue hover:bg-brand-blue-light shadow-sm">
|
||||
<Link href={`/jury/stages/${assignment.stage.id}/projects/${assignment.project.id}/evaluate`}>
|
||||
<Link href={`/jury/competitions/${assignment.round.id}/projects/${assignment.project.id}/evaluate`}>
|
||||
{isDraft ? 'Continue' : 'Evaluate'}
|
||||
</Link>
|
||||
</Button>
|
||||
) : (
|
||||
<Button variant="ghost" size="sm" asChild className="h-7 px-2">
|
||||
<Link href={`/jury/stages/${assignment.stage.id}/projects/${assignment.project.id}`}>
|
||||
<Link href={`/jury/competitions/${assignment.round.id}/projects/${assignment.project.id}`}>
|
||||
View
|
||||
</Link>
|
||||
</Button>
|
||||
@@ -478,7 +474,7 @@ async function JuryDashboardContent() {
|
||||
<CardContent>
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<Link
|
||||
href="/jury/stages"
|
||||
href="/jury/competitions"
|
||||
className="group flex items-center gap-4 rounded-xl border border-border/60 p-4 transition-all duration-200 hover:border-brand-blue/30 hover:bg-brand-blue/5 hover:-translate-y-0.5 hover:shadow-md dark:hover:border-brand-teal/30 dark:hover:bg-brand-teal/5"
|
||||
>
|
||||
<div className="rounded-xl bg-blue-50 p-3 transition-colors group-hover:bg-blue-100 dark:bg-blue-950/40 dark:group-hover:bg-blue-950/60">
|
||||
@@ -490,7 +486,7 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
</Link>
|
||||
<Link
|
||||
href="/jury/stages"
|
||||
href="/jury/competitions"
|
||||
className="group flex items-center gap-4 rounded-xl border border-border/60 p-4 transition-all duration-200 hover:border-brand-teal/30 hover:bg-brand-teal/5 hover:-translate-y-0.5 hover:shadow-md"
|
||||
>
|
||||
<div className="rounded-xl bg-teal-50 p-3 transition-colors group-hover:bg-teal-100 dark:bg-teal-950/40 dark:group-hover:bg-teal-950/60">
|
||||
@@ -509,8 +505,8 @@ async function JuryDashboardContent() {
|
||||
|
||||
{/* Right column */}
|
||||
<div className="lg:col-span-5 space-y-4">
|
||||
{/* Active Stages */}
|
||||
{activeStages.length > 0 && (
|
||||
{/* Active Rounds */}
|
||||
{activeRounds.length > 0 && (
|
||||
<AnimatedCard index={8}>
|
||||
<Card className="overflow-hidden">
|
||||
<div className="h-1 w-full bg-gradient-to-r from-brand-blue via-brand-teal to-brand-blue" />
|
||||
@@ -528,21 +524,21 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{activeStages.map(({ stage, assignments: stageAssignments }) => {
|
||||
const stageCompleted = stageAssignments.filter(
|
||||
(a) => a.evaluation?.status === 'SUBMITTED'
|
||||
{activeRounds.map(({ round, assignments: roundAssignments }: { round: (typeof assignments)[0]['round']; assignments: typeof assignments }) => {
|
||||
const roundCompleted = roundAssignments.filter(
|
||||
(a: typeof assignments[0]) => a.evaluation?.status === 'SUBMITTED'
|
||||
).length
|
||||
const stageTotal = stageAssignments.length
|
||||
const stageProgress =
|
||||
stageTotal > 0 ? (stageCompleted / stageTotal) * 100 : 0
|
||||
const isAlmostDone = stageProgress >= 80
|
||||
const deadline = graceByStage.get(stage.id) ?? (stage.windowCloseAt ? new Date(stage.windowCloseAt) : null)
|
||||
const roundTotal = roundAssignments.length
|
||||
const roundProgress =
|
||||
roundTotal > 0 ? (roundCompleted / roundTotal) * 100 : 0
|
||||
const isAlmostDone = roundProgress >= 80
|
||||
const deadline = graceByRound.get(round.id) ?? (round.windowCloseAt ? new Date(round.windowCloseAt) : null)
|
||||
const isUrgent = deadline && (deadline.getTime() - now.getTime()) < 24 * 60 * 60 * 1000
|
||||
const program = stage.track.pipeline.program
|
||||
const program = round.competition.program
|
||||
|
||||
return (
|
||||
<div
|
||||
key={stage.id}
|
||||
key={round.id}
|
||||
className={cn(
|
||||
'rounded-xl border p-4 space-y-3 transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md',
|
||||
isUrgent
|
||||
@@ -552,7 +548,7 @@ async function JuryDashboardContent() {
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<h3 className="font-semibold text-brand-blue dark:text-brand-teal">{stage.name}</h3>
|
||||
<h3 className="font-semibold text-brand-blue dark:text-brand-teal">{round.name}</h3>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
{program.name} · {program.year}
|
||||
</p>
|
||||
@@ -568,13 +564,13 @@ async function JuryDashboardContent() {
|
||||
<div className="flex justify-between text-sm">
|
||||
<span className="text-muted-foreground">Progress</span>
|
||||
<span className="font-semibold tabular-nums">
|
||||
{stageCompleted}/{stageTotal}
|
||||
{roundCompleted}/{roundTotal}
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative h-2.5 w-full overflow-hidden rounded-full bg-muted/60">
|
||||
<div
|
||||
className="h-full rounded-full bg-gradient-to-r from-brand-teal to-brand-blue transition-all duration-500 ease-out"
|
||||
style={{ width: `${stageProgress}%` }}
|
||||
style={{ width: `${roundProgress}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -585,16 +581,16 @@ async function JuryDashboardContent() {
|
||||
deadline={deadline}
|
||||
label="Deadline:"
|
||||
/>
|
||||
{stage.windowCloseAt && (
|
||||
{round.windowCloseAt && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
({formatDateOnly(stage.windowCloseAt)})
|
||||
({formatDateOnly(round.windowCloseAt)})
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button asChild size="sm" className="w-full bg-brand-blue hover:bg-brand-blue-light shadow-sm">
|
||||
<Link href={`/jury/stages/${stage.id}/assignments`}>
|
||||
<Link href={`/jury/competitions/${round.id}`}>
|
||||
View Assignments
|
||||
<ArrowRight className="ml-2 h-4 w-4" />
|
||||
</Link>
|
||||
@@ -608,7 +604,7 @@ async function JuryDashboardContent() {
|
||||
)}
|
||||
|
||||
{/* No active stages */}
|
||||
{activeStages.length === 0 && (
|
||||
{activeRounds.length === 0 && (
|
||||
<AnimatedCard index={8}>
|
||||
<Card>
|
||||
<CardContent className="flex flex-col items-center justify-center py-6 text-center">
|
||||
@@ -624,8 +620,8 @@ async function JuryDashboardContent() {
|
||||
</AnimatedCard>
|
||||
)}
|
||||
|
||||
{/* Completion Summary by Stage */}
|
||||
{Object.keys(assignmentsByStage).length > 0 && (
|
||||
{/* Completion Summary by Round */}
|
||||
{Object.keys(assignmentsByRound).length > 0 && (
|
||||
<AnimatedCard index={9}>
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
@@ -637,14 +633,14 @@ async function JuryDashboardContent() {
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{Object.values(assignmentsByStage).map(({ stage, assignments: stageAssignments }) => {
|
||||
const done = stageAssignments.filter((a) => a.evaluation?.status === 'SUBMITTED').length
|
||||
const total = stageAssignments.length
|
||||
{Object.values(assignmentsByRound).map(({ round, assignments: roundAssignments }: { round: (typeof assignments)[0]['round']; assignments: typeof assignments }) => {
|
||||
const done = roundAssignments.filter((a: typeof assignments[0]) => a.evaluation?.status === 'SUBMITTED').length
|
||||
const total = roundAssignments.length
|
||||
const pct = total > 0 ? Math.round((done / total) * 100) : 0
|
||||
return (
|
||||
<div key={stage.id} className="space-y-2">
|
||||
<div key={round.id} className="space-y-2">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="font-medium truncate">{stage.name}</span>
|
||||
<span className="font-medium truncate">{round.name}</span>
|
||||
<div className="flex items-baseline gap-1 shrink-0 ml-2">
|
||||
<span className="font-bold tabular-nums text-brand-blue dark:text-brand-teal">{pct}%</span>
|
||||
<span className="text-xs text-muted-foreground">({done}/{total})</span>
|
||||
|
||||
Reference in New Issue
Block a user