From 7db5433361b1a116321d988f3e3a04bdcd7190c5 Mon Sep 17 00:00:00 2001 From: MuhammadKhalilzadeh Date: Mon, 8 Jul 2024 22:55:23 +0330 Subject: [PATCH] Renaming the variable --- Server/controllers/checkController.js | 6 +++--- Server/db/MongoDB.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Server/controllers/checkController.js b/Server/controllers/checkController.js index 7a556f3a5..3014937fb 100644 --- a/Server/controllers/checkController.js +++ b/Server/controllers/checkController.js @@ -42,13 +42,13 @@ const getChecks = async (req, res, next) => { return; } - let limitedTo = null; + let limit = null; try { if (req.query && req.query.limit) { - limitedTo = parseInt(req.query.limit); + limit = parseInt(req.query.limit); } - const checks = await req.db.getChecks(req.params.monitorId, limitedTo); + const checks = await req.db.getChecks(req.params.monitorId, limit); return res .status(200) .json({ success: true, msg: successMessages.CHECK_GET, data: checks }); diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index 67e86ea3f..75fd2310a 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -414,10 +414,10 @@ const createCheck = async (checkData) => { * @throws {Error} */ -const getChecks = async (monitorId, limitedTo) => { +const getChecks = async (monitorId, limit) => { try { - if (limitedTo) { - const checks = await Check.find({ monitorId }).sort({ createdAt: -1 }).limit(limitedTo); + if (limit) { + const checks = await Check.find({ monitorId }).sort({ createdAt: -1 }).limit(limit); return checks; } const checks = await Check.find({ monitorId })