mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-20 16:49:46 -06:00
Add customization to limiting
This commit is contained in:
@@ -42,8 +42,13 @@ const getChecks = async (req, res, next) => {
|
||||
return;
|
||||
}
|
||||
|
||||
let limitedTo = null;
|
||||
|
||||
try {
|
||||
const checks = await req.db.getChecks(req.params.monitorId);
|
||||
if (req.query && req.query.limit) {
|
||||
limitedTo = parseInt(req.query.limit);
|
||||
}
|
||||
const checks = await req.db.getChecks(req.params.monitorId, limitedTo);
|
||||
return res
|
||||
.status(200)
|
||||
.json({ success: true, msg: successMessages.CHECK_GET, data: checks });
|
||||
|
||||
@@ -414,9 +414,13 @@ const createCheck = async (checkData) => {
|
||||
* @throws {Error}
|
||||
*/
|
||||
|
||||
const getChecks = async (monitorId) => {
|
||||
const getChecks = async (monitorId, limitedTo) => {
|
||||
try {
|
||||
const checks = await Check.find({ monitorId }).sort({ createdAt: -1 }).limit(25);
|
||||
if (limitedTo) {
|
||||
const checks = await Check.find({ monitorId }).sort({ createdAt: -1 }).limit(limitedTo);
|
||||
return checks;
|
||||
}
|
||||
const checks = await Check.find({ monitorId })
|
||||
return checks;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user