From 912c2dccc96d4c19015dbd1905b47a753470a20f Mon Sep 17 00:00:00 2001 From: AhmedHamed3699 Date: Fri, 29 Dec 2023 13:30:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20fix:=20stats=20bug=20has=20been?= =?UTF-8?q?=20hunted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/controllers/stats.controller.js | 8 ++++---- server/routes/api.route.js | 15 ++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/server/controllers/stats.controller.js b/server/controllers/stats.controller.js index c4011863..032aecbe 100644 --- a/server/controllers/stats.controller.js +++ b/server/controllers/stats.controller.js @@ -25,7 +25,7 @@ const statsController = { [req.currentTerm.termNumber] ) const absenceRate = computeAbsenceRate(result.rows[0]) - if (!absenceRate) { + if (absenceRate == null) { return res.status(400).json({ error: 'There are no attendance records', }) @@ -73,7 +73,7 @@ const statsController = { [req.currentTerm.termNumber, unitCaptainId] ) const absenceRate = computeAbsenceRate(result.rows[0]) - if (!absenceRate) { + if (absenceRate == null) { return res.status(400).json({ error: 'There are no attendance records for this unit', }) @@ -120,7 +120,7 @@ const statsController = { [sectorBaseName, sectorSuffixName, req.currentTerm.termNumber] ) const absenceRate = computeAbsenceRate(result.rows[0]) - if (!absenceRate) { + if (absenceRate == null) { return res.status(400).json({ error: 'There are no attendance records for this sector', }) @@ -166,7 +166,7 @@ const statsController = { [scoutId, req.currentTerm.termNumber] ) const absenceRate = computeAbsenceRate(result.rows[0]) - if (!absenceRate) { + if (absenceRate == null) { return res.status(400).json({ error: 'There are no attendance records for this scout', }) diff --git a/server/routes/api.route.js b/server/routes/api.route.js index 1402fc15..92a3b869 100644 --- a/server/routes/api.route.js +++ b/server/routes/api.route.js @@ -1,6 +1,5 @@ import { Router } from 'express' import authMiddleware from '../middlewares/auth.middleware.js' -import checkRankMiddleware from '../middlewares/checkRank.middleware.js' import authRouter from './auth.route.js' import statsRouter from './stats.route.js' import financeRouter from './finance.route.js' @@ -14,15 +13,9 @@ import captainAttendanceRouter from './captainAttendance.route.js' import activitiesRouter from './activities.route.js' const apiRouter = Router() -apiRouter.use("/auth", authRouter); -apiRouter.use("/stats", authMiddleware, statsRouter); -apiRouter.use( - "/finance", - authMiddleware, - // TODO: add for certain functtions remove from others - // checkRankMiddleware('general'), - financeRouter -); +apiRouter.use('/auth', authRouter) +apiRouter.use('/stats', authMiddleware, statsRouter) +apiRouter.use('/finance', authMiddleware, financeRouter) apiRouter.use('/term', authMiddleware, termRouter) apiRouter.use('/captain', authMiddleware, captainRouter) apiRouter.use('/alert', authMiddleware, alertRouter) @@ -32,4 +25,4 @@ apiRouter.use('/scoutAttendance', authMiddleware, scoutAttendanceRouter) apiRouter.use('/captainAttendance', authMiddleware, captainAttendanceRouter) apiRouter.use('/activities', activitiesRouter) -export default apiRouter; +export default apiRouter