Skip to content

Commit

Permalink
Merge pull request #4041 from airqo-platform/staging
Browse files Browse the repository at this point in the history
move to production
  • Loading branch information
Baalmart authored Dec 10, 2024
2 parents 5e45c95 + 9f58416 commit 3c9423e
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 10 deletions.
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-3d3f6c14-1733315928
tag: prod-5e45c956-1733849508
api:
name: airqo-analytics-api
label: analytics-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/analytics/values-stage.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-stage-analytics-celery-worker
reportJob: eu.gcr.io/airqo-250220/airqo-stage-analytics-report-job
devicesSummaryJob: eu.gcr.io/airqo-250220/airqo-stage-analytics-devices-summary-job
tag: stage-014ccd0f-1733315863
tag: stage-dd764c29-1733849460
api:
name: airqo-stage-analytics-api
label: sta-alytics-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/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-device-registry-api
tag: prod-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
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-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
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-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
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-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
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-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
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-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
containers: eu.gcr.io/airqo-250220/airqo-workflows
tag: prod-ae2e15a3-1733844050
tag: prod-5e45c956-1733849508
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion src/device-registry/models/Cohort.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ cohortSchema.statics.list = async function(
.sort({ createdAt: -1 })
.project(inclusionProjection)
.project(exclusionProjection)
.groups({
.group({
_id: "$_id",
visibility: { $first: "$visibility" },
cohort_tags: { $first: "$cohort_tags" },
Expand Down
71 changes: 71 additions & 0 deletions src/device-registry/utils/scripts/new-bulk-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const axios = require("axios");
const isEmpty = require("is-empty");

const url = "http://localhost:3000/api/v2/devices/sites";
const config = {
headers: {
Authorization: "",
},
};

const NETWORK_MAPPINGS = {
// iqair: "permian-health",
// usembassy: "us-embassy",
// urbanbetter: "urban-better",
// kcca: "kcca",
// airqo: "airqo",
// Add more mappings as needed
};

const DEFAULT_GROUP = "unknown";

axios
.get(url, config)
.then(async (response) => {
const groups = response.data.sites
.map((site) => {
// Look up the group based on network, with a fallback to a default
const group = NETWORK_MAPPINGS[site.network] || DEFAULT_GROUP;

// Optionally log devices with unknown networks
if (group === DEFAULT_GROUP) {
console.log(
`Unrecognized network for device ${site.name}: ${site.network}`
);
}

return group;
})
// Remove any 'unknown' groups if you want only mapped networks
.filter((group) => group !== DEFAULT_GROUP);

console.log("the data:");
console.dir({ groups });

// Process devices in batches
for (let i = 0; i < response.data.sites.length; i += 10) {
const batch = response.data.sites.slice(i, i + 10);

for (const site of batch) {
const group = NETWORK_MAPPINGS[site.network] || DEFAULT_GROUP;

if (group !== DEFAULT_GROUP) {
const url = `http://localhost:3000/api/v2/devices/sites?id=${site._id}`;
const data = { groups: [group] };
// console.log("the data:");
// console.dir(data);

try {
// Uncomment if you want to make the PUT request
const putResponse = await axios.put(url, data, config);
console.log("PUT response:", putResponse.data);
} catch (error) {
console.error("PUT error:", error.message);
}
}
}
}
})
.catch((error) => {
console.error("GET error:", error);
});

0 comments on commit 3c9423e

Please sign in to comment.