fix: save roundId on admin file upload and group assignments by round
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s

The admin upload flow accepted roundId but never wrote it to the
ProjectFile record, causing all admin-uploaded files to appear under
"General". Fixed the create call, the listByProject filter, and the
listByProjectForStage grouping to also use the direct roundId field.

Jury assignments on the project detail page are now grouped by round
with per-round completion counts instead of a flat list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-04-12 23:20:48 -04:00
parent 2344f2e4ff
commit c7488b3e07
3 changed files with 182 additions and 142 deletions

View File

@@ -206,6 +206,7 @@ export const fileRouter = router({
const file = await ctx.prisma.projectFile.create({
data: {
projectId: input.projectId,
roundId: input.roundId ?? null,
fileType: input.fileType,
fileName: input.fileName,
mimeType: input.mimeType,
@@ -341,7 +342,10 @@ export const fileRouter = router({
const where: Record<string, unknown> = { projectId: input.projectId }
if (input.roundId) {
where.requirement = { roundId: input.roundId }
where.OR = [
{ requirement: { roundId: input.roundId } },
{ roundId: input.roundId, requirementId: null },
]
}
return ctx.prisma.projectFile.findMany({
@@ -429,7 +433,8 @@ export const fileRouter = router({
projectId: input.projectId,
OR: [
{ requirement: { roundId: { in: eligibleRoundIds } } },
{ requirementId: null },
{ roundId: { in: eligibleRoundIds }, requirementId: null },
{ roundId: null, requirementId: null },
],
},
include: {
@@ -454,7 +459,8 @@ export const fileRouter = router({
files: typeof files
}> = []
const generalFiles = files.filter((f) => !f.requirementId)
// Files with no round association at all go to General
const generalFiles = files.filter((f) => !f.requirementId && !f.roundId)
if (generalFiles.length > 0) {
grouped.push({
roundId: null,
@@ -465,7 +471,9 @@ export const fileRouter = router({
}
for (const round of eligibleRounds) {
const roundFiles = files.filter((f) => f.requirement?.roundId === round.id)
const roundFiles = files.filter(
(f) => f.requirement?.roundId === round.id || (!f.requirementId && f.roundId === round.id)
)
if (roundFiles.length > 0) {
grouped.push({
roundId: round.id,