Skip to content

Commit

Permalink
Merge pull request #58 from CMP26Projects/Convert-To-Procedures
Browse files Browse the repository at this point in the history
🚑 fix: stats bug has been hunted
  • Loading branch information
amir-kedis authored Dec 29, 2023
2 parents a68e8bf + 912c2dc commit fb16f96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
8 changes: 4 additions & 4 deletions server/controllers/stats.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
Expand Down Expand Up @@ -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',
})
Expand Down Expand Up @@ -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',
})
Expand Down Expand Up @@ -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',
})
Expand Down
15 changes: 4 additions & 11 deletions server/routes/api.route.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
Expand All @@ -32,4 +25,4 @@ apiRouter.use('/scoutAttendance', authMiddleware, scoutAttendanceRouter)
apiRouter.use('/captainAttendance', authMiddleware, captainAttendanceRouter)
apiRouter.use('/activities', activitiesRouter)

export default apiRouter;
export default apiRouter

0 comments on commit fb16f96

Please sign in to comment.