Skip to content

Commit adf8706

Browse files
committed
fix: also consider users with cursus ending in the future as active
1 parent d96be61 commit adf8706

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/handlers/points.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ export const createScore = async function(prisma: PrismaClient, type: CodamCoali
3232
},
3333
},
3434
cursus_users: {
35-
where: {
36-
cursus_id: CURSUS_ID,
37-
end_at: null, // Make sure to only get active cursus users
35+
where: { // only get active cursus_users for the relevant cursus
36+
OR: [
37+
{
38+
cursus_id: CURSUS_ID,
39+
end_at: null,
40+
},
41+
{
42+
cursus_id: CURSUS_ID,
43+
end_at: {
44+
gt: scoreDate, // also consider cursus_users that were still active at the score creation date
45+
},
46+
},
47+
],
3848
},
3949
select: {
4050
id: true,

src/routes/quiz.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,18 @@ export const isQuizAvailable = async function(user: IntraUser | ExpressIntraUser
7676
},
7777
cursus_users: {
7878
where: {
79-
cursus_id: CURSUS_ID,
80-
end_at: null,
79+
OR: [ // only consider active cursus users for the relevant cursus
80+
{
81+
cursus_id: CURSUS_ID,
82+
end_at: null,
83+
},
84+
{
85+
cursus_id: CURSUS_ID,
86+
end_at: {
87+
gt: currentDate, // also consider cursus_users that are still active at the current date
88+
},
89+
},
90+
],
8191
},
8292
select: {
8393
id: true,

0 commit comments

Comments
 (0)