Skip to content

Commit 7c72fd3

Browse files
committed
fix: wrong query to fetch currently ongoing season
1 parent 2f8357f commit 7c72fd3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/routes/admin/dashboard.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import { CoalitionScore, getCoalitionScore, getScoresPerType } from '../../utils
44

55
export const setupAdminDashboardRoutes = function(app: Express, prisma: PrismaClient): void {
66
app.get('/admin', async (req, res) => {
7+
const now = new Date();
8+
79
// Get current bloc deadline
810
const currentBlocDeadline = await prisma.intraBlocDeadline.findFirst({
911
orderBy: {
1012
end_at: 'desc',
1113
},
1214
where: {
15+
begin_at: {
16+
gte: now,
17+
},
1318
end_at: {
14-
lt: new Date(),
15-
gte: new Date(),
19+
lt: now,
1620
},
1721
},
1822
});

src/routes/home.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const setupHomeRoutes = function(app: Express, prisma: PrismaClient): voi
1010
keepSessionInfo: true,
1111
}), async (req, res) => {
1212
const user = req.user as ExpressIntraUser;
13+
const now = new Date();
1314

1415
// Get all coalitions
1516
const coalitions = await prisma.codamCoalition.findMany({
@@ -50,9 +51,11 @@ export const setupHomeRoutes = function(app: Express, prisma: PrismaClient): voi
5051
end_at: 'desc',
5152
},
5253
where: {
54+
begin_at: {
55+
gte: now,
56+
},
5357
end_at: {
54-
lt: new Date(),
55-
gte: new Date(),
58+
lt: now,
5659
},
5760
},
5861
});
@@ -62,7 +65,7 @@ export const setupHomeRoutes = function(app: Express, prisma: PrismaClient): voi
6265
},
6366
where: {
6467
begin_at: {
65-
gt: new Date(),
68+
gt: now,
6669
},
6770
},
6871
});
@@ -109,9 +112,6 @@ export const setupHomeRoutes = function(app: Express, prisma: PrismaClient): voi
109112
// Check if quiz is currently available
110113
const quiz_available = await isQuizAvailable(user, prisma);
111114

112-
// Current datetime
113-
const now = new Date();
114-
115115
return res.render('home.njk', {
116116
coalitions,
117117
coalitionsObject,

0 commit comments

Comments
 (0)