Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to production #4084

Merged
merged 10 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k8s/analytics/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion k8s/auth-service/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/auth-service/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-airqo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-kcca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
2 changes: 1 addition & 1 deletion k8s/predict/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion k8s/spatial/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/website/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
21 changes: 19 additions & 2 deletions src/device-registry/bin/jobs/v2.1-store-readings-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -282,4 +298,5 @@ module.exports = {
updateEntityStatus,
isEntityActive,
updateOfflineDevices,
updateOfflineSites,
};
Loading