feat(scheduler): in-process matching scheduler with audit + admin endpoints

- Add in-process scheduler service triggered by ENABLE_SCHEDULER
- Record runs in new matching_runs table; throttle per-event and log stats
- Add admin endpoints: POST /api/admin/events/:slug/run-now and GET /api/admin/events/:slug/matching-runs
- Wire scheduler start/stop in server and add ENV flags + compose defaults
- Prisma schema: add MatchingRun model and relation
- Update env examples for scheduler configuration
This commit is contained in:
Radosław Gierwiało
2025-11-30 13:14:02 +01:00
parent a110ddb6a6
commit 537dd112ff
9 changed files with 338 additions and 11 deletions

View File

@@ -102,6 +102,7 @@ model Event {
checkinToken EventCheckinToken?
userHeats EventUserHeat[]
recordingSuggestions RecordingSuggestion[]
matchingRuns MatchingRun[]
@@map("events")
}
@@ -298,3 +299,22 @@ model RecordingSuggestion {
@@index([recorderId])
@@map("recording_suggestions")
}
// Matching runs audit log
model MatchingRun {
id Int @id @default(autoincrement())
eventId Int @map("event_id")
trigger String @db.VarChar(20) // 'manual' | 'scheduler'
status String @default("running") @db.VarChar(20) // 'running' | 'success' | 'error'
startedAt DateTime @default(now()) @map("started_at")
endedAt DateTime? @map("ended_at")
matchedCount Int @default(0) @map("matched_count")
notFoundCount Int @default(0) @map("not_found_count")
error String? @db.Text
// Relations
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
@@index([eventId, startedAt])
@@map("matching_runs")
}