Skip to content

Commit 53db60c

Browse files
committed
fix: apply base difficulty to assumed to be rush projects
1 parent 3ad4e0d commit 53db60c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ model IntraProject {
372372
difficulty Int?
373373
description String?
374374
exam Boolean
375+
// parent_id Int? // Would be good to have this for rushes, maybe
375376
376377
created_at DateTime
377378
updated_at DateTime

src/routes/hooks/projects_users.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { CodamCoalitionFixedType, PrismaClient } from '@prisma/client';
33
import { WebhookHandledStatus, respondWebHookHandledStatus } from '../hooks';
44
import { handleFixedPointScore } from '../../handlers/points';
55

6+
const DEFAULT_RUSH_DIFFICULTY = 1000;
7+
68
export interface ProjectUser {
79
id: number;
810
project_id: number | undefined; // only defined in webhook
@@ -71,6 +73,10 @@ export const handleProjectsUserUpdateWebhook = async function(prisma: PrismaClie
7173
points = fixedPointType.point_amount;
7274
}
7375
else {
76+
if ((project.slug.startsWith('rushes-') || project.slug.startsWith('42cursus-rushes-')) && !project.difficulty) {
77+
// Set a custom difficulty for rushes if not set
78+
project.difficulty = DEFAULT_RUSH_DIFFICULTY;
79+
}
7480
// Get the project difficulty
7581
if (project.difficulty === 0 || project.difficulty === null) {
7682
console.log(`Project ${projectId} has no difficulty set, skipping score creation...`);

0 commit comments

Comments
 (0)