Skip to content

Commit

Permalink
some changes in user stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawy03 committed Nov 29, 2024
1 parent c8b34ce commit 0d38d4a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/src/controllers/users/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,18 @@ const getHowManyUsers = async (req: Request, res: Response) => {
res.status(ResponseStatusCodes.BAD_REQUEST).json({ message: error.message, data: [] });
}
};

const getHowManyUsersByMonth = async (req: Request, res: Response) => {
try {
const month = req.body.month;
const year = req.body.year;
if (month < 1 || month > 12 || !Number.isInteger(year)) {
const month = parseInt(req.query.month as string, 10);
const year = parseInt(req.query.year as string, 10);

if (!month || !year || month < 1 || month > 12 || !Number.isInteger(year)) {
res.status(ResponseStatusCodes.BAD_REQUEST).json({
message: 'Invalid month or year',
});
return;
}

const users = await userRepo.getHowManyUsersByMonth(month, year);
res.status(ResponseStatusCodes.OK).json({ message: 'Users fetched successfully', data: users.length });
} catch (error: any) {
Expand Down

0 comments on commit 0d38d4a

Please sign in to comment.