Skip to content

Commit 77f1900

Browse files
authored
Merge pull request #4071 from airqo-platform/staging
move to production
2 parents ec35f75 + 05a9f5e commit 77f1900

File tree

11 files changed

+117
-65
lines changed

11 files changed

+117
-65
lines changed

k8s/analytics/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ images:
88
celeryWorker: eu.gcr.io/airqo-250220/airqo-analytics-celery-worker
99
reportJob: eu.gcr.io/airqo-250220/airqo-analytics-report-job
1010
devicesSummaryJob: eu.gcr.io/airqo-250220/airqo-analytics-devices-summary-job
11-
tag: prod-7c9244bc-1734092169
11+
tag: prod-ec35f75d-1734096419
1212
api:
1313
name: airqo-analytics-api
1414
label: analytics-api

k8s/analytics/values-stage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ images:
88
celeryWorker: eu.gcr.io/airqo-250220/airqo-stage-analytics-celery-worker
99
reportJob: eu.gcr.io/airqo-250220/airqo-stage-analytics-report-job
1010
devicesSummaryJob: eu.gcr.io/airqo-250220/airqo-stage-analytics-devices-summary-job
11-
tag: stage-40bbbd59-1734088481
11+
tag: stage-549b8475-1734096374
1212
api:
1313
name: airqo-stage-analytics-api
1414
label: sta-alytics-api

k8s/auth-service/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-auth-api
9-
tag: prod-a00e783d-1734092401
9+
tag: prod-ec35f75d-1734096419
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/exceedance/values-prod-airqo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ app:
44
configmap: env-exceedance-production
55
image:
66
repository: eu.gcr.io/airqo-250220/airqo-exceedance-job
7-
tag: prod-7c9244bc-1734092169
7+
tag: prod-ec35f75d-1734096419
88
nameOverride: ''
99
fullnameOverride: ''

k8s/exceedance/values-prod-kcca.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ app:
44
configmap: env-exceedance-production
55
image:
66
repository: eu.gcr.io/airqo-250220/kcca-exceedance-job
7-
tag: prod-a00e783d-1734092401
7+
tag: prod-ec35f75d-1734096419
88
nameOverride: ''
99
fullnameOverride: ''

k8s/predict/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ images:
77
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
88
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
99
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
10-
tag: prod-7c9244bc-1734092169
10+
tag: prod-ec35f75d-1734096419
1111
api:
1212
name: airqo-prediction-api
1313
label: prediction-api

k8s/spatial/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-spatial-api
9-
tag: prod-7c9244bc-1734092169
9+
tag: prod-ec35f75d-1734096419
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/website/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app:
66
replicaCount: 3
77
image:
88
repository: eu.gcr.io/airqo-250220/airqo-website-api
9-
tag: prod-7c9244bc-1734092169
9+
tag: prod-ec35f75d-1734096419
1010
nameOverride: ''
1111
fullnameOverride: ''
1212
podAnnotations: {}

k8s/workflows/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ images:
1010
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
1111
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
1212
containers: eu.gcr.io/airqo-250220/airqo-workflows
13-
tag: prod-a00e783d-1734092401
13+
tag: prod-ec35f75d-1734096419
1414
nameOverride: ''
1515
fullnameOverride: ''
1616
podAnnotations: {}

src/auth-service/models/Preference.js

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ PreferenceSchema.pre(
234234
const processObjectId = (id) => {
235235
if (!id) return null;
236236
if (id instanceof mongoose.Types.ObjectId) return id;
237+
if (typeof id === "string" && id.trim() === "") return null;
237238
try {
238239
return mongoose.Types.ObjectId(id);
239240
} catch (error) {
@@ -242,37 +243,43 @@ PreferenceSchema.pre(
242243
}
243244
};
244245

245-
// Comprehensive ID fields processing
246-
const idFieldsToProcess = [
246+
// Define field categories
247+
const singleIdFields = [
248+
"user_id",
249+
"group_id",
247250
"airqloud_id",
248-
"airqloud_ids",
249251
"grid_id",
250-
"grid_ids",
251252
"cohort_id",
252-
"cohort_ids",
253253
"network_id",
254+
];
255+
const arrayIdFields = [
256+
"airqloud_ids",
257+
"grid_ids",
258+
"cohort_ids",
254259
"network_ids",
255-
"group_id",
256-
"group_ids",
257260
"site_ids",
258261
"device_ids",
262+
"group_ids",
263+
];
264+
const selectedArrayFields = [
265+
"selected_sites",
266+
"selected_grids",
267+
"selected_devices",
268+
"selected_cohorts",
269+
"selected_airqlouds",
259270
];
260271

261-
idFieldsToProcess.forEach((field) => {
272+
// Process single ID fields
273+
singleIdFields.forEach((field) => {
262274
if (updateData[field]) {
263-
if (Array.isArray(updateData[field])) {
264-
updateData[field] = updateData[field].map(processObjectId);
265-
} else {
266-
updateData[field] = processObjectId(updateData[field]);
267-
}
275+
updateData[field] = processObjectId(updateData[field]);
268276
}
269277
});
270278

271279
// Validate user_id
272280
if (!updateData.user_id) {
273281
return next(new Error("user_id is required"));
274282
}
275-
updateData.user_id = processObjectId(updateData.user_id);
276283

277284
// Set default values if not provided
278285
const defaultFields = [
@@ -393,29 +400,33 @@ PreferenceSchema.pre(
393400
};
394401

395402
// Process selected arrays
396-
Object.keys(selectedArrayProcessors).forEach((field) => {
403+
selectedArrayFields.forEach((field) => {
397404
if (updateData[field]) {
398405
updateData[field] = updateData[field].map(
399406
selectedArrayProcessors[field]
400407
);
408+
409+
// Use $addToSet for selected arrays
410+
updateData.$addToSet = {
411+
...updateData.$addToSet,
412+
[field]: {
413+
$each: updateData[field],
414+
},
415+
};
416+
delete updateData[field];
401417
}
402418
});
403419

404-
// Prepare $addToSet for array fields to prevent duplicates
405-
const arrayFieldsToAddToSet = [
406-
...idFieldsToProcess,
407-
"selected_sites",
408-
"selected_grids",
409-
"selected_devices",
410-
"selected_cohorts",
411-
"selected_airqlouds",
412-
];
413-
414-
arrayFieldsToAddToSet.forEach((field) => {
420+
// Process array ID fields
421+
arrayIdFields.forEach((field) => {
415422
if (updateData[field]) {
416-
updateData.$addToSet = updateData.$addToSet || {};
417-
updateData.$addToSet[field] = {
418-
$each: updateData[field],
423+
updateData.$addToSet = {
424+
...updateData.$addToSet,
425+
[field]: {
426+
$each: Array.isArray(updateData[field])
427+
? updateData[field].map(processObjectId)
428+
: [processObjectId(updateData[field])],
429+
},
419430
};
420431
delete updateData[field];
421432
}

0 commit comments

Comments
 (0)