mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-20 16:49:46 -06:00
limiting getChecks to the last 25 checks
This commit is contained in:
@@ -4,7 +4,7 @@ const {
|
||||
getChecksParamValidation,
|
||||
deleteChecksParamValidation,
|
||||
} = require("../validation/joi");
|
||||
const { successMessages } = require("../utils/messages");
|
||||
const { successMessages, errorMessages } = require("../utils/messages");
|
||||
const SERVICE_NAME = "check";
|
||||
|
||||
const createCheck = async (req, res, next) => {
|
||||
@@ -44,9 +44,15 @@ const getChecks = async (req, res, next) => {
|
||||
|
||||
try {
|
||||
const checks = await req.db.getChecks(req.params.monitorId);
|
||||
return res
|
||||
.status(200)
|
||||
.json({ success: true, msg: successMessages.CHECK_GET, data: checks });
|
||||
if (checks) {
|
||||
return res
|
||||
.status(200)
|
||||
.json({ success: true, msg: successMessages.CHECK_GET, data: checks });
|
||||
} else {
|
||||
return res
|
||||
.status(404)
|
||||
.json({ success: false, msg: errorMessages.CHECKS_NOT_FOUND, data: [] })
|
||||
}
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
next(error);
|
||||
|
||||
@@ -416,7 +416,7 @@ const createCheck = async (checkData) => {
|
||||
|
||||
const getChecks = async (monitorId) => {
|
||||
try {
|
||||
const checks = await Check.find({ monitorId });
|
||||
const checks = await Check.find({ monitorId }).sort({ createdAt: -1 }).limit(25);
|
||||
return checks;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
@@ -38,6 +38,9 @@ const errorMessages = {
|
||||
JOB_QUEUE_WORKER_CLOSE: "Error closing worker",
|
||||
JOB_QUEUE_DELETE_JOB: "Job not found in queue",
|
||||
JOB_QUEUE_OBLITERATE: "Error obliterating queue",
|
||||
|
||||
// Checks Error
|
||||
CHECKS_NOT_FOUND: "No Checks found for this monitor",
|
||||
};
|
||||
|
||||
const successMessages = {
|
||||
|
||||
Reference in New Issue
Block a user