From 3b8454b1544e393e78850a7bc0b684bbc6e4f062 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 11 Nov 2024 08:52:51 +0800 Subject: [PATCH] Update status service to handle new schema --- Server/service/statusService.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Server/service/statusService.js b/Server/service/statusService.js index 64705e122..22254d050 100644 --- a/Server/service/statusService.js +++ b/Server/service/statusService.js @@ -83,6 +83,7 @@ class StatusService { responseTime, message, }; + if (type === "pagespeed") { const categories = payload.lighthouseResult?.categories; const audits = payload.lighthouseResult?.audits; @@ -101,10 +102,13 @@ class StatusService { } if (type === "hardware") { - check.cpu = payload?.cpu ?? {}; - check.memory = payload?.memory ?? {}; - check.disk = payload?.disk ?? {}; - check.host = payload?.host ?? {}; + const { cpu, memory, disk, host } = payload?.data ?? {}; + const { errors } = payload; + check.cpu = cpu ?? {}; + check.memory = memory ?? {}; + check.disk = disk ?? {}; + check.host = host ?? {}; + check.errors = errors ?? []; } return check; }; @@ -131,6 +135,7 @@ class StatusService { hardware: this.db.createHardwareCheck, }; const operation = operationMap[networkResponse.type]; + const check = this.buildCheck(networkResponse); await operation(check); } catch (error) {