Merge branch 'develop' into feat/be/hardware-details

This commit is contained in:
Alex Holliday committed 2024-12-31 17:39:19 -08:00
commit cb425b2b3b
39 files changed
+1377 -913

No files matched your search

+9 -2
View File
@@ -224,15 +224,22 @@ const getDateRange = (dateRange) => {
* @returns {Promise<Object>} All checks and date-ranged checks
*/
const getMonitorChecks = async (monitorId, model, dateRange, sortOrder) => {
const indexSpec = {
monitorId: 1,
createdAt: sortOrder, // This will be 1 or -1
};
const [checksAll, checksForDateRange] = await Promise.all([
model.find({ monitorId }).sort({ createdAt: sortOrder }),
model.find({ monitorId }).sort({ createdAt: sortOrder }).hint(indexSpec).lean(),
model
.find({
monitorId,
createdAt: { $gte: dateRange.start, $lte: dateRange.end },
})
.sort({ createdAt: sortOrder }),
.hint(indexSpec)
.lean(),
]);
return { checksAll, checksForDateRange };
};