refactor: tech debt batch 3 — type safety + assignment router split
All checks were successful
Build and Push Docker Image / build (push) Successful in 13m4s
All checks were successful
Build and Push Docker Image / build (push) Successful in 13m4s
#5 — Replaced 55x PrismaClient | any with proper Prisma types across 8 files - Service files: PrismaClient | any → PrismaClient, tx: any → Prisma.TransactionClient - Fixed 4 real bugs uncovered by typing: - mentor-workspace.ts: wrong FK fields (mentorAssignmentId → workspaceId, role → senderRole) - ai-shortlist.ts: untyped string passed to CompetitionCategory enum filter - result-lock.ts: unknown passed where Prisma.InputJsonValue required #9 — Split assignment.ts (2,775 lines) into 6 focused files: - shared.ts (93 lines) — MOVABLE_EVAL_STATUSES, buildBatchNotifications, getCandidateJurors - assignment-crud.ts (473 lines) — 8 core CRUD procedures - assignment-suggestions.ts (880 lines) — AI suggestions + job runner - assignment-notifications.ts (138 lines) — 2 notification procedures - assignment-redistribution.ts (1,162 lines) — 8 reassign/transfer procedures - index.ts (15 lines) — barrel export with router merge, zero frontend changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import { getOpenAI, getConfiguredModel, buildCompletionParams } from '@/lib/open
|
||||
import { logAIUsage, extractTokenUsage } from '@/server/utils/ai-usage'
|
||||
import { classifyAIError, logAIError } from './ai-errors'
|
||||
import { extractMultipleFileContents } from './file-content-extractor'
|
||||
import type { PrismaClient } from '@prisma/client'
|
||||
import type { PrismaClient, CompetitionCategory } from '@prisma/client'
|
||||
|
||||
// ─── Types ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -95,14 +95,14 @@ async function generateCategoryShortlist(
|
||||
rubric?: string
|
||||
aiParseFiles: boolean
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ recommendations: ShortlistRecommendation[]; tokensUsed: number; errors: string[] }> {
|
||||
const { roundId, category, topN, rubric, aiParseFiles } = params
|
||||
|
||||
// Load projects with evaluations for this category
|
||||
const projects = await prisma.project.findMany({
|
||||
where: {
|
||||
competitionCategory: category,
|
||||
competitionCategory: category as CompetitionCategory,
|
||||
assignments: { some: { roundId } },
|
||||
},
|
||||
include: {
|
||||
@@ -320,7 +320,7 @@ export async function generateShortlist(
|
||||
rubric?: string
|
||||
aiParseFiles?: boolean
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<ShortlistResult> {
|
||||
const {
|
||||
roundId,
|
||||
|
||||
@@ -19,13 +19,13 @@ type WorkspaceResult = { success: boolean; errors?: string[] }
|
||||
* Activate a mentor workspace for a given assignment.
|
||||
*/
|
||||
export async function activateWorkspace(
|
||||
mentorAssignmentId: string,
|
||||
workspaceId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<WorkspaceResult> {
|
||||
try {
|
||||
const assignment = await prisma.mentorAssignment.findUnique({
|
||||
where: { id: mentorAssignmentId },
|
||||
where: { id: workspaceId },
|
||||
})
|
||||
|
||||
if (!assignment) {
|
||||
@@ -36,9 +36,9 @@ export async function activateWorkspace(
|
||||
return { success: false, errors: ['Workspace is already enabled'] }
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
await tx.mentorAssignment.update({
|
||||
where: { id: mentorAssignmentId },
|
||||
where: { id: workspaceId },
|
||||
data: {
|
||||
workspaceEnabled: true,
|
||||
workspaceOpenAt: new Date(),
|
||||
@@ -49,7 +49,7 @@ export async function activateWorkspace(
|
||||
data: {
|
||||
eventType: 'mentor_workspace.activated',
|
||||
entityType: 'MentorAssignment',
|
||||
entityId: mentorAssignmentId,
|
||||
entityId: workspaceId,
|
||||
actorId,
|
||||
detailsJson: {
|
||||
projectId: assignment.projectId,
|
||||
@@ -64,7 +64,7 @@ export async function activateWorkspace(
|
||||
userId: actorId,
|
||||
action: 'WORKSPACE_ACTIVATE',
|
||||
entityType: 'MentorAssignment',
|
||||
entityId: mentorAssignmentId,
|
||||
entityId: workspaceId,
|
||||
detailsJson: { projectId: assignment.projectId },
|
||||
})
|
||||
})
|
||||
@@ -86,15 +86,15 @@ export async function activateWorkspace(
|
||||
*/
|
||||
export async function sendMessage(
|
||||
params: {
|
||||
mentorAssignmentId: string
|
||||
workspaceId: string
|
||||
senderId: string
|
||||
message: string
|
||||
role: 'MENTOR_ROLE' | 'APPLICANT_ROLE' | 'ADMIN_ROLE'
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
const assignment = await prisma.mentorAssignment.findUnique({
|
||||
where: { id: params.mentorAssignmentId },
|
||||
where: { id: params.workspaceId },
|
||||
})
|
||||
|
||||
if (!assignment) {
|
||||
@@ -107,11 +107,11 @@ export async function sendMessage(
|
||||
|
||||
return prisma.mentorMessage.create({
|
||||
data: {
|
||||
mentorAssignmentId: params.mentorAssignmentId,
|
||||
workspaceId: params.workspaceId,
|
||||
projectId: assignment.projectId,
|
||||
senderId: params.senderId,
|
||||
message: params.message,
|
||||
role: params.role,
|
||||
senderRole: params.role,
|
||||
},
|
||||
include: {
|
||||
sender: { select: { id: true, name: true, email: true } },
|
||||
@@ -123,11 +123,11 @@ export async function sendMessage(
|
||||
* Get messages for a workspace.
|
||||
*/
|
||||
export async function getMessages(
|
||||
mentorAssignmentId: string,
|
||||
prisma: PrismaClient | any,
|
||||
workspaceId: string,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
return prisma.mentorMessage.findMany({
|
||||
where: { mentorAssignmentId },
|
||||
where: { workspaceId },
|
||||
include: {
|
||||
sender: { select: { id: true, name: true, email: true, role: true } },
|
||||
},
|
||||
@@ -140,7 +140,7 @@ export async function getMessages(
|
||||
*/
|
||||
export async function markRead(
|
||||
messageId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<void> {
|
||||
await prisma.mentorMessage.update({
|
||||
where: { id: messageId },
|
||||
@@ -155,7 +155,7 @@ export async function markRead(
|
||||
*/
|
||||
export async function uploadFile(
|
||||
params: {
|
||||
mentorAssignmentId: string
|
||||
workspaceId: string
|
||||
uploadedByUserId: string
|
||||
fileName: string
|
||||
mimeType: string
|
||||
@@ -164,10 +164,10 @@ export async function uploadFile(
|
||||
objectKey: string
|
||||
description?: string
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
const assignment = await prisma.mentorAssignment.findUnique({
|
||||
where: { id: params.mentorAssignmentId },
|
||||
where: { id: params.workspaceId },
|
||||
})
|
||||
|
||||
if (!assignment) {
|
||||
@@ -180,7 +180,7 @@ export async function uploadFile(
|
||||
|
||||
return prisma.mentorFile.create({
|
||||
data: {
|
||||
mentorAssignmentId: params.mentorAssignmentId,
|
||||
mentorAssignmentId: params.workspaceId,
|
||||
uploadedByUserId: params.uploadedByUserId,
|
||||
fileName: params.fileName,
|
||||
mimeType: params.mimeType,
|
||||
@@ -205,7 +205,7 @@ export async function addFileComment(
|
||||
content: string
|
||||
parentCommentId?: string
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
return prisma.mentorFileComment.create({
|
||||
data: {
|
||||
@@ -233,7 +233,7 @@ export async function promoteFile(
|
||||
slotKey: string
|
||||
promotedById: string
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ success: boolean; errors?: string[] }> {
|
||||
try {
|
||||
const file = await prisma.mentorFile.findUnique({
|
||||
@@ -251,7 +251,7 @@ export async function promoteFile(
|
||||
return { success: false, errors: ['File is already promoted'] }
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
// Mark file as promoted
|
||||
await tx.mentorFile.update({
|
||||
where: { id: params.mentorFileId },
|
||||
|
||||
@@ -46,7 +46,7 @@ export async function lockResults(
|
||||
lockedById: string
|
||||
resultSnapshot: unknown
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<LockResult> {
|
||||
try {
|
||||
// Validate deliberation is finalized
|
||||
@@ -84,7 +84,7 @@ export async function lockResults(
|
||||
}
|
||||
}
|
||||
|
||||
const lock = await prisma.$transaction(async (tx: any) => {
|
||||
const lock = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const created = await tx.resultLock.create({
|
||||
data: {
|
||||
competitionId: params.competitionId,
|
||||
@@ -109,7 +109,7 @@ export async function lockResults(
|
||||
snapshotJson: {
|
||||
timestamp: new Date().toISOString(),
|
||||
emittedBy: 'result-lock',
|
||||
resultSnapshot: params.resultSnapshot,
|
||||
resultSnapshot: params.resultSnapshot as Prisma.InputJsonValue,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -155,7 +155,7 @@ export async function unlockResults(
|
||||
unlockedById: string
|
||||
reason: string
|
||||
},
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<UnlockResult> {
|
||||
try {
|
||||
const lock = await prisma.resultLock.findUnique({
|
||||
@@ -166,7 +166,7 @@ export async function unlockResults(
|
||||
return { success: false, errors: ['Result lock not found'] }
|
||||
}
|
||||
|
||||
const event = await prisma.$transaction(async (tx: any) => {
|
||||
const event = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const created = await tx.resultUnlockEvent.create({
|
||||
data: {
|
||||
resultLockId: params.resultLockId,
|
||||
@@ -226,7 +226,7 @@ export async function isLocked(
|
||||
competitionId: string,
|
||||
roundId: string,
|
||||
category: CompetitionCategory,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<LockStatus> {
|
||||
const lock = await prisma.resultLock.findFirst({
|
||||
where: { competitionId, roundId, category },
|
||||
@@ -265,7 +265,7 @@ export async function isLocked(
|
||||
*/
|
||||
export async function getLockHistory(
|
||||
competitionId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
return prisma.resultLock.findMany({
|
||||
where: { competitionId },
|
||||
|
||||
@@ -75,7 +75,7 @@ const PREVIOUS_ROUND_FAMILIARITY_BONUS = 10
|
||||
export async function previewRoundAssignment(
|
||||
roundId: string,
|
||||
config?: { honorIntents?: boolean; requiredReviews?: number },
|
||||
prisma?: PrismaClient | any,
|
||||
prisma?: PrismaClient,
|
||||
): Promise<AssignmentPreview> {
|
||||
const db = prisma ?? (await import('@/lib/prisma')).prisma
|
||||
const honorIntents = config?.honorIntents ?? true
|
||||
@@ -390,7 +390,7 @@ export async function executeRoundAssignment(
|
||||
roundId: string,
|
||||
assignments: Array<{ userId: string; projectId: string }>,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ created: number; errors: string[] }> {
|
||||
const db = prisma ?? (await import('@/lib/prisma')).prisma
|
||||
const errors: string[] = []
|
||||
@@ -398,7 +398,7 @@ export async function executeRoundAssignment(
|
||||
|
||||
for (const assignment of assignments) {
|
||||
try {
|
||||
await db.$transaction(async (tx: any) => {
|
||||
await db.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
// Create assignment record
|
||||
await tx.assignment.create({
|
||||
data: {
|
||||
@@ -483,7 +483,7 @@ export async function executeRoundAssignment(
|
||||
export async function getRoundCoverageReport(
|
||||
roundId: string,
|
||||
requiredReviews: number = 3,
|
||||
prisma?: PrismaClient | any,
|
||||
prisma?: PrismaClient,
|
||||
): Promise<CoverageReport> {
|
||||
const db = prisma ?? (await import('@/lib/prisma')).prisma
|
||||
|
||||
@@ -558,7 +558,7 @@ export async function getRoundCoverageReport(
|
||||
export async function getUnassignedQueue(
|
||||
roundId: string,
|
||||
requiredReviews: number = 3,
|
||||
prisma?: PrismaClient | any,
|
||||
prisma?: PrismaClient,
|
||||
) {
|
||||
const db = prisma ?? (await import('@/lib/prisma')).prisma
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ const VALID_PROJECT_TRANSITIONS: Record<string, string[]> = {
|
||||
export async function activateRound(
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<RoundTransitionResult> {
|
||||
try {
|
||||
const round = await prisma.round.findUnique({
|
||||
@@ -127,7 +127,7 @@ export async function activateRound(
|
||||
windowData.windowOpenAt = now
|
||||
}
|
||||
|
||||
const updated = await prisma.$transaction(async (tx: any) => {
|
||||
const updated = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const result = await tx.round.update({
|
||||
where: { id: roundId },
|
||||
data: { status: 'ROUND_ACTIVE', ...windowData },
|
||||
@@ -234,7 +234,7 @@ export async function activateRound(
|
||||
export async function closeRound(
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<RoundTransitionResult> {
|
||||
try {
|
||||
const round = await prisma.round.findUnique({
|
||||
@@ -267,7 +267,7 @@ export async function closeRound(
|
||||
}
|
||||
}
|
||||
|
||||
const updated = await prisma.$transaction(async (tx: any) => {
|
||||
const updated = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const result = await tx.round.update({
|
||||
where: { id: roundId },
|
||||
data: { status: 'ROUND_CLOSED' },
|
||||
@@ -383,7 +383,7 @@ export async function closeRound(
|
||||
export async function archiveRound(
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<RoundTransitionResult> {
|
||||
try {
|
||||
const round = await prisma.round.findUnique({ where: { id: roundId } })
|
||||
@@ -399,7 +399,7 @@ export async function archiveRound(
|
||||
}
|
||||
}
|
||||
|
||||
const updated = await prisma.$transaction(async (tx: any) => {
|
||||
const updated = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const result = await tx.round.update({
|
||||
where: { id: roundId },
|
||||
data: { status: 'ROUND_ARCHIVED' },
|
||||
@@ -456,7 +456,7 @@ export async function archiveRound(
|
||||
export async function reopenRound(
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<RoundTransitionResult & { pausedRounds?: string[] }> {
|
||||
try {
|
||||
const round = await prisma.round.findUnique({
|
||||
@@ -475,7 +475,7 @@ export async function reopenRound(
|
||||
}
|
||||
}
|
||||
|
||||
const result = await prisma.$transaction(async (tx: any) => {
|
||||
const result = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
// Pause any subsequent active rounds in the same competition
|
||||
const subsequentActiveRounds = await tx.round.findMany({
|
||||
where: {
|
||||
@@ -601,7 +601,7 @@ export async function transitionProject(
|
||||
roundId: string,
|
||||
newState: ProjectRoundStateValue,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
options?: { adminOverride?: boolean },
|
||||
): Promise<ProjectRoundTransitionResult> {
|
||||
try {
|
||||
@@ -624,7 +624,7 @@ export async function transitionProject(
|
||||
return { success: false, errors: [`Project ${projectId} not found`] }
|
||||
}
|
||||
|
||||
const result = await prisma.$transaction(async (tx: any) => {
|
||||
const result = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const now = new Date()
|
||||
|
||||
// Upsert ProjectRoundState
|
||||
@@ -722,7 +722,7 @@ export async function batchTransitionProjects(
|
||||
roundId: string,
|
||||
newState: ProjectRoundStateValue,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
options?: { adminOverride?: boolean },
|
||||
): Promise<BatchProjectTransitionResult> {
|
||||
const succeeded: string[] = []
|
||||
@@ -754,7 +754,7 @@ export async function batchTransitionProjects(
|
||||
|
||||
export async function getProjectRoundStates(
|
||||
roundId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
const states = await prisma.projectRoundState.findMany({
|
||||
where: { roundId },
|
||||
@@ -803,7 +803,7 @@ export async function getProjectRoundStates(
|
||||
export async function getProjectRoundState(
|
||||
projectId: string,
|
||||
roundId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
return prisma.projectRoundState.findUnique({
|
||||
where: { projectId_roundId: { projectId, roundId } },
|
||||
@@ -823,7 +823,7 @@ export async function checkRequirementsAndTransition(
|
||||
projectId: string,
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ transitioned: boolean; newState?: string }> {
|
||||
try {
|
||||
// Get all required FileRequirements for this round (legacy model)
|
||||
@@ -939,7 +939,7 @@ export async function batchCheckRequirementsAndTransition(
|
||||
roundId: string,
|
||||
projectIds: string[],
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ transitionedCount: number; projectIds: string[] }> {
|
||||
if (projectIds.length === 0) return { transitionedCount: 0, projectIds: [] }
|
||||
|
||||
@@ -1051,7 +1051,7 @@ export async function triggerInProgressOnActivity(
|
||||
projectId: string,
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<void> {
|
||||
try {
|
||||
const prs = await prisma.projectRoundState.findUnique({
|
||||
@@ -1078,7 +1078,7 @@ export async function checkEvaluationCompletionAndTransition(
|
||||
projectId: string,
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ transitioned: boolean }> {
|
||||
try {
|
||||
const prs = await prisma.projectRoundState.findUnique({
|
||||
|
||||
@@ -75,7 +75,7 @@ export type ConfirmFinalizationResult = {
|
||||
export async function processRoundClose(
|
||||
roundId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<{ processed: number }> {
|
||||
const round = await prisma.round.findUnique({
|
||||
where: { id: roundId },
|
||||
@@ -305,7 +305,7 @@ export async function processRoundClose(
|
||||
const now = new Date()
|
||||
|
||||
if (transitionUpdates.length > 0) {
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
// Step through intermediate states in bulk
|
||||
// PENDING → IN_PROGRESS for projects going to COMPLETED
|
||||
const pendingToCompleted = transitionUpdates.filter(
|
||||
@@ -402,7 +402,7 @@ export async function processRoundClose(
|
||||
|
||||
export async function getFinalizationSummary(
|
||||
roundId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<FinalizationSummary> {
|
||||
const round = await prisma.round.findUniqueOrThrow({
|
||||
where: { id: roundId },
|
||||
@@ -568,7 +568,7 @@ export async function confirmFinalization(
|
||||
rejectionMessage?: string
|
||||
},
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<ConfirmFinalizationResult> {
|
||||
// Validate: round is CLOSED, not already finalized, grace period expired
|
||||
const round = await prisma.round.findUniqueOrThrow({
|
||||
@@ -612,7 +612,7 @@ export async function confirmFinalization(
|
||||
: 'Next Round'
|
||||
|
||||
// Execute finalization in a transaction
|
||||
const result = await prisma.$transaction(async (tx: any) => {
|
||||
const result = await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const projectStates = await tx.projectRoundState.findMany({
|
||||
where: { roundId, proposedOutcome: { not: null } },
|
||||
include: {
|
||||
|
||||
@@ -34,7 +34,7 @@ export type SubmissionValidationResult = {
|
||||
export async function openWindow(
|
||||
windowId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<WindowLifecycleResult> {
|
||||
try {
|
||||
const window = await prisma.submissionWindow.findUnique({ where: { id: windowId } })
|
||||
@@ -47,7 +47,7 @@ export async function openWindow(
|
||||
return { success: false, errors: ['Cannot open a locked window'] }
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
await tx.submissionWindow.update({
|
||||
where: { id: windowId },
|
||||
data: {
|
||||
@@ -93,7 +93,7 @@ export async function openWindow(
|
||||
export async function closeWindow(
|
||||
windowId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<WindowLifecycleResult> {
|
||||
try {
|
||||
const window = await prisma.submissionWindow.findUnique({ where: { id: windowId } })
|
||||
@@ -102,7 +102,7 @@ export async function closeWindow(
|
||||
return { success: false, errors: [`Submission window ${windowId} not found`] }
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
const data: Record<string, unknown> = {
|
||||
windowCloseAt: new Date(),
|
||||
}
|
||||
@@ -155,7 +155,7 @@ export async function closeWindow(
|
||||
export async function lockWindow(
|
||||
windowId: string,
|
||||
actorId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<WindowLifecycleResult> {
|
||||
try {
|
||||
const window = await prisma.submissionWindow.findUnique({ where: { id: windowId } })
|
||||
@@ -168,7 +168,7 @@ export async function lockWindow(
|
||||
return { success: false, errors: ['Window is already locked'] }
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx: any) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
await tx.submissionWindow.update({
|
||||
where: { id: windowId },
|
||||
data: { isLocked: true },
|
||||
@@ -212,7 +212,7 @@ export async function lockWindow(
|
||||
*/
|
||||
export async function checkDeadlinePolicy(
|
||||
windowId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<DeadlineStatus> {
|
||||
const window = await prisma.submissionWindow.findUnique({ where: { id: windowId } })
|
||||
|
||||
@@ -273,7 +273,7 @@ export async function validateSubmission(
|
||||
projectId: string,
|
||||
windowId: string,
|
||||
files: Array<{ mimeType: string; size: number; requirementId?: string }>,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<SubmissionValidationResult> {
|
||||
const errors: string[] = []
|
||||
|
||||
@@ -327,7 +327,7 @@ export async function validateSubmission(
|
||||
*/
|
||||
export async function isWindowReadOnly(
|
||||
windowId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
): Promise<boolean> {
|
||||
const status = await checkDeadlinePolicy(windowId, prisma)
|
||||
return status.status === 'LOCKED' || status.status === 'CLOSED'
|
||||
@@ -340,7 +340,7 @@ export async function isWindowReadOnly(
|
||||
*/
|
||||
export async function getVisibleWindows(
|
||||
roundId: string,
|
||||
prisma: PrismaClient | any,
|
||||
prisma: PrismaClient,
|
||||
) {
|
||||
const visibility = await prisma.roundSubmissionVisibility.findMany({
|
||||
where: { roundId, canView: true },
|
||||
|
||||
Reference in New Issue
Block a user