Update status service to handle new schema

This commit is contained in:
Alex Holliday committed 2024-11-11 08:52:51 +08:00
1 parent d1061be028
commit 3b8454b154
1 file changed
+9 -4
+9 -4
View File
@@ -83,6 +83,7 @@ class StatusService {
responseTime, responseTime,
message, message,
}; };
if (type === "pagespeed") { if (type === "pagespeed") {
const categories = payload.lighthouseResult?.categories; const categories = payload.lighthouseResult?.categories;
const audits = payload.lighthouseResult?.audits; const audits = payload.lighthouseResult?.audits;
@@ -101,10 +102,13 @@ class StatusService {
} }
if (type === "hardware") { if (type === "hardware") {
check.cpu = payload?.cpu ?? {}; const { cpu, memory, disk, host } = payload?.data ?? {};
check.memory = payload?.memory ?? {}; const { errors } = payload;
check.disk = payload?.disk ?? {}; check.cpu = cpu ?? {};
check.host = payload?.host ?? {}; check.memory = memory ?? {};
check.disk = disk ?? {};
check.host = host ?? {};
check.errors = errors ?? [];
} }
return check; return check;
}; };
@@ -131,6 +135,7 @@ class StatusService {
hardware: this.db.createHardwareCheck, hardware: this.db.createHardwareCheck,
}; };
const operation = operationMap[networkResponse.type]; const operation = operationMap[networkResponse.type];
const check = this.buildCheck(networkResponse); const check = this.buildCheck(networkResponse);
await operation(check); await operation(check);
} catch (error) { } catch (error) {