feat: round finalization with ranking-based outcomes + award pool notifications
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m0s
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m0s
- processRoundClose EVALUATION uses ranking scores + advanceMode config (threshold vs count) to auto-set proposedOutcome instead of defaulting all to PASSED - Advancement emails generate invite tokens for passwordless users with "Create Your Account" CTA; rejection emails have no link - Finalization UI shows account stats (invite vs dashboard link counts) - Fixed getFinalizationSummary ranking query (was using non-existent rankingsJson) - New award pool notification system: getAwardSelectionNotificationTemplate email, notifyEligibleProjects mutation with invite token generation, "Notify Pool" button on award detail page with custom message dialog Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
47
src/app/api/cron/process-grace-periods/route.ts
Normal file
47
src/app/api/cron/process-grace-periods/route.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { processRoundClose } from '@/server/services/round-finalization'
|
||||
|
||||
export async function GET(request: NextRequest): Promise<NextResponse> {
|
||||
const cronSecret = request.headers.get('x-cron-secret')
|
||||
|
||||
if (!cronSecret || cronSecret !== process.env.CRON_SECRET) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const now = new Date()
|
||||
|
||||
// Find rounds with expired grace periods that haven't been finalized
|
||||
const expiredRounds = await prisma.round.findMany({
|
||||
where: {
|
||||
status: 'ROUND_CLOSED',
|
||||
gracePeriodEndsAt: { lt: now },
|
||||
finalizedAt: null,
|
||||
},
|
||||
select: { id: true, name: true },
|
||||
})
|
||||
|
||||
const results: Array<{ roundId: string; roundName: string; processed: number }> = []
|
||||
|
||||
for (const round of expiredRounds) {
|
||||
try {
|
||||
const result = await processRoundClose(round.id, 'system-cron', prisma)
|
||||
results.push({ roundId: round.id, roundName: round.name, processed: result.processed })
|
||||
} catch (err) {
|
||||
console.error(`[Cron] processRoundClose failed for round ${round.id}:`, err)
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
processedRounds: results.length,
|
||||
results,
|
||||
timestamp: now.toISOString(),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Cron grace period processing failed:', error)
|
||||
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user