From 52f4f80da3fa693b1b2e6341aafd87d99e7e29e9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:26:21 +0300 Subject: [PATCH 1/9] Update auth service staging image tag to stage-2c219406-1734171902 --- k8s/auth-service/values-stage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/auth-service/values-stage.yaml b/k8s/auth-service/values-stage.yaml index 3bcc291f61..6b0e0f52f6 100644 --- a/k8s/auth-service/values-stage.yaml +++ b/k8s/auth-service/values-stage.yaml @@ -6,7 +6,7 @@ app: replicaCount: 2 image: repository: eu.gcr.io/airqo-250220/airqo-stage-auth-api - tag: stage-331742e7-1734167859 + tag: stage-2c219406-1734171902 nameOverride: '' fullnameOverride: '' podAnnotations: {} From 527b24dd59ac55c8b504c5db8b17870e012c69fe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:26:41 +0300 Subject: [PATCH 2/9] Update AirQo exceedance production image tag to prod-40a3081d-1734171941 --- k8s/exceedance/values-prod-airqo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/exceedance/values-prod-airqo.yaml b/k8s/exceedance/values-prod-airqo.yaml index c5d4231a8c..977a614da9 100644 --- a/k8s/exceedance/values-prod-airqo.yaml +++ b/k8s/exceedance/values-prod-airqo.yaml @@ -4,6 +4,6 @@ app: configmap: env-exceedance-production image: repository: eu.gcr.io/airqo-250220/airqo-exceedance-job - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 nameOverride: '' fullnameOverride: '' From 14621b457b52c60a3853b14cea93732a27b423bf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:26:51 +0300 Subject: [PATCH 3/9] Update KCCA exceedance production image tag to prod-40a3081d-1734171941 --- k8s/exceedance/values-prod-kcca.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/exceedance/values-prod-kcca.yaml b/k8s/exceedance/values-prod-kcca.yaml index bc689c40fd..81e708b36e 100644 --- a/k8s/exceedance/values-prod-kcca.yaml +++ b/k8s/exceedance/values-prod-kcca.yaml @@ -4,6 +4,6 @@ app: configmap: env-exceedance-production image: repository: eu.gcr.io/airqo-250220/kcca-exceedance-job - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 nameOverride: '' fullnameOverride: '' From dc04ae897dbbf711a092da6b758a7ecaae4cf05f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:27:16 +0300 Subject: [PATCH 4/9] Update auth service production image tag to prod-40a3081d-1734171941 --- k8s/auth-service/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/auth-service/values-prod.yaml b/k8s/auth-service/values-prod.yaml index bec9461345..d976f48502 100644 --- a/k8s/auth-service/values-prod.yaml +++ b/k8s/auth-service/values-prod.yaml @@ -6,7 +6,7 @@ app: replicaCount: 3 image: repository: eu.gcr.io/airqo-250220/airqo-auth-api - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 nameOverride: '' fullnameOverride: '' podAnnotations: {} From 4b1e2ca54df2bb8c1c505f4a432057eeb89e0f72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:27:37 +0300 Subject: [PATCH 5/9] Update website production image tag to prod-40a3081d-1734171941 --- k8s/website/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/website/values-prod.yaml b/k8s/website/values-prod.yaml index ece08123a7..28e907ba71 100644 --- a/k8s/website/values-prod.yaml +++ b/k8s/website/values-prod.yaml @@ -6,7 +6,7 @@ app: replicaCount: 3 image: repository: eu.gcr.io/airqo-250220/airqo-website-api - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 nameOverride: '' fullnameOverride: '' podAnnotations: {} From 49503073ecbb6ad6b7fbecc1a993987042336b69 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:28:35 +0300 Subject: [PATCH 6/9] Update analytics production image tag to prod-40a3081d-1734171941 --- k8s/analytics/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/analytics/values-prod.yaml b/k8s/analytics/values-prod.yaml index b4d480ff6e..366b3f5f6e 100644 --- a/k8s/analytics/values-prod.yaml +++ b/k8s/analytics/values-prod.yaml @@ -8,7 +8,7 @@ images: celeryWorker: eu.gcr.io/airqo-250220/airqo-analytics-celery-worker reportJob: eu.gcr.io/airqo-250220/airqo-analytics-report-job devicesSummaryJob: eu.gcr.io/airqo-250220/airqo-analytics-devices-summary-job - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 api: name: airqo-analytics-api label: analytics-api From 3cc94d8252389c3f5886a5b427a770bd129347f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:29:09 +0300 Subject: [PATCH 7/9] Update predict production image tag to prod-40a3081d-1734171941 --- k8s/predict/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/predict/values-prod.yaml b/k8s/predict/values-prod.yaml index 2c412464cc..2650065f6d 100644 --- a/k8s/predict/values-prod.yaml +++ b/k8s/predict/values-prod.yaml @@ -7,7 +7,7 @@ images: predictJob: eu.gcr.io/airqo-250220/airqo-predict-job trainJob: eu.gcr.io/airqo-250220/airqo-train-job predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 api: name: airqo-prediction-api label: prediction-api From a5707421a35ecbadc99f572e5915089d5e47e0cd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:34:15 +0300 Subject: [PATCH 8/9] Update spatial production image tag to prod-40a3081d-1734171941 --- k8s/spatial/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/spatial/values-prod.yaml b/k8s/spatial/values-prod.yaml index a36bcd56c2..2eb71e4cf2 100644 --- a/k8s/spatial/values-prod.yaml +++ b/k8s/spatial/values-prod.yaml @@ -6,7 +6,7 @@ app: replicaCount: 3 image: repository: eu.gcr.io/airqo-250220/airqo-spatial-api - tag: prod-1f1d50ac-1734167898 + tag: prod-40a3081d-1734171941 nameOverride: '' fullnameOverride: '' podAnnotations: {} From 30abfb092a0195b88b36ef32947cf1b27f20282f Mon Sep 17 00:00:00 2001 From: baalmart Date: Sat, 14 Dec 2024 13:46:03 +0300 Subject: [PATCH 9/9] adding a helper function to update offline Sites --- .../bin/jobs/v2.1-store-readings-job.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/device-registry/bin/jobs/v2.1-store-readings-job.js b/src/device-registry/bin/jobs/v2.1-store-readings-job.js index 222be35d75..4f9eea1a69 100644 --- a/src/device-registry/bin/jobs/v2.1-store-readings-job.js +++ b/src/device-registry/bin/jobs/v2.1-store-readings-job.js @@ -182,6 +182,22 @@ async function updateOfflineDevices(data) { ); } +// Helper function to update offline sites +async function updateOfflineSites(data) { + const activeSiteIds = new Set(data.map((doc) => doc.site_id).filter(Boolean)); + const thresholdTime = moment() + .subtract(INACTIVE_THRESHOLD, "milliseconds") + .toDate(); + + await SiteModel("airqo").updateMany( + { + _id: { $nin: Array.from(activeSiteIds) }, + lastActive: { $lt: thresholdTime }, + }, + { isOnline: false } + ); +} + // Main function to fetch and store data async function fetchAndStoreDataIntoReadingsModel() { const batchProcessor = new BatchProcessor(50); @@ -259,8 +275,8 @@ async function fetchAndStoreDataIntoReadingsModel() { ); } - // Update offline devices - await updateOfflineDevices(data); + // Update offline devices and sites + await Promise.all([updateOfflineDevices(data), updateOfflineSites(data)]); logText("All data inserted successfully and offline devices updated"); } catch (error) { @@ -282,4 +298,5 @@ module.exports = { updateEntityStatus, isEntityActive, updateOfflineDevices, + updateOfflineSites, };