Add missing else block

This commit is contained in:
Alex Holliday committed 2024-09-04 11:45:54 -07:00
1 parent df16bf3db5
commit ffc132e19a
3 files changed
+16 -6

No files matched your search

+2 -1
View File
@@ -213,10 +213,11 @@ const PageSpeedDetails = () => {
monitorId,
"desc",
50,
null,
"day",
null,
null
);
console.log(res.data.data);
setMonitor(res?.data?.data ?? {});
setAudits(res?.data?.data?.checks?.[0]?.audits ?? []);
} catch (error) {
+13 -4
View File
@@ -147,7 +147,6 @@ const getMonitorStatsById = async (req) => {
}
// This effectively removes limit, returning all checks
if (limit === undefined) limit = 0;
// Default sort order is newest -> oldest
sortOrder = sortOrder === "asc" ? 1 : -1;
@@ -182,8 +181,9 @@ const getMonitorStatsById = async (req) => {
if (monitor.type === "http" || monitor.type === "ping") {
// HTTP/PING Specific stats
monitorStats.avgResponseTime = getAverageResponseTime(checksForDateRange);
monitorStats.uptime = getUptimePercentage(checksForDateRange);
monitorStats.periodAvgResponseTime =
getAverageResponseTime(checksForDateRange);
monitorStats.periodUptime = getUptimePercentage(checksForDateRange);
// Aggregate data
let groupedChecks;
@@ -198,6 +198,15 @@ const getMonitorStatsById = async (req) => {
acc[time].checks.push(check);
return acc;
}, {});
} else {
groupedChecks = checksForDateRange.reduce((acc, check) => {
const day = new Date(check.createdAt).toISOString().split("T")[0]; // Extract the date part
if (!acc[day]) {
acc[day] = { day, checks: [] };
}
acc[day].checks.push(check);
return acc;
}, {});
}
// Map grouped checks to stats
@@ -220,7 +229,7 @@ const getMonitorStatsById = async (req) => {
monitorStats.aggregateData = aggregateData;
}
monitorStats.incidents = getIncidents(checksForDateRange);
monitorStats.periodIncidents = getIncidents(checksForDateRange);
// If more than numToDisplay checks, pick every nth check
+1 -1
View File
@@ -197,7 +197,6 @@ class NetworkService {
*/
async handlePagespeed(job) {
let isAlive;
try {
const url = job.data.url;
const response = await axios.get(
@@ -297,6 +296,7 @@ class NetworkService {
async logAndStoreCheck(data, writeToDB) {
try {
const insertedCheck = await writeToDB(data);
console.log(insertedCheck);
return insertedCheck.status;
} catch (error) {
console.log(error);