Skip to content

Commit

Permalink
Merge pull request #2435 from airqo-platform/staging
Browse files Browse the repository at this point in the history
move to production
  • Loading branch information
Baalmart authored Nov 5, 2023
2 parents 6ea06af + 86bad23 commit 58e0f4e
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 20 deletions.
2 changes: 1 addition & 1 deletion k8s/airflow/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ images:
repositories:
initContainer: eu.gcr.io/airqo-250220/airqo-apache-airflow-xcom
containers: eu.gcr.io/airqo-250220/airqo-apache-airflow
tag: prod-301153b4-1699175317
tag: prod-6ea06af8-1699219770
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-monitor/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ images:
deviceMonitor: eu.gcr.io/airqo-250220/airqo-device-monitor-api
celeryBeat: eu.gcr.io/airqo-250220/airqo-device-monitor-celery-beat
celeryWorker: eu.gcr.io/airqo-250220/airqo-device-monitor-celery-worker
tag: prod-301153b4-1699175317
tag: prod-6ea06af8-1699219770
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
nameOverride: ''
fullnameOverride: ''
2 changes: 1 addition & 1 deletion k8s/gp-model/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
namespace: production
configMap: env-gp-model-production
images:
tag: prod-301153b4-1699175317
tag: prod-6ea06af8-1699219770
repositories:
cronJob: eu.gcr.io/airqo-250220/airqo-gp-model-job
brokerConsumer: eu.gcr.io/airqo-250220/airqo-gp-model-broker-consumer
Expand Down
2 changes: 1 addition & 1 deletion k8s/incentives/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-incentives-api
tag: prod-301153b4-1699175317
tag: prod-6ea06af8-1699219770
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
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-301153b4-1699175317
tag: prod-6ea06af8-1699219770
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
46 changes: 36 additions & 10 deletions src/device-registry/controllers/create-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ const GridModel = require("@models/Grid");
const distanceUtil = require("@utils/distance");
const mongoose = require("mongoose");
const ObjectId = mongoose.Types.ObjectId;
const generateFilter = require("@utils/generate-filter");

const getSitesFromAirQloud = async ({ tenant = "airqo", airqloud_id } = {}) => {
try {
const airQloud = await AirQloudModel(tenant).findById(airqloud_id);
const airQloud = await AirQloudModel(tenant)
.findById(airqloud_id)
.lean();
logObject("airQloud", airQloud);

if (!airQloud) {
return {
Expand Down Expand Up @@ -66,9 +70,18 @@ const getSitesFromAirQloud = async ({ tenant = "airqo", airqloud_id } = {}) => {

const getSitesFromGrid = async ({ tenant = "airqo", grid_id } = {}) => {
try {
const grid = await GridModel(tenant).findById(grid_id);
const request = {
query: {
grid_id,
},
};

const filter = generateFilter.grids(request);
const reseponseFromListGrid = await GridModel(tenant).list({ filter });

const gridDetails = reseponseFromListGrid.data[0];

if (!grid) {
if (reseponseFromListGrid.data.length > 1 || isEmpty(gridDetails)) {
return {
success: false,
message: "Bad Request Error",
Expand All @@ -77,7 +90,7 @@ const getSitesFromGrid = async ({ tenant = "airqo", grid_id } = {}) => {
};
}

const sites = grid.sites || [];
const sites = gridDetails.sites || [];

if (sites.length === 0) {
return {
Expand Down Expand Up @@ -114,20 +127,30 @@ const getSitesFromGrid = async ({ tenant = "airqo", grid_id } = {}) => {

const getDevicesFromCohort = async ({ tenant = "airqo", cohort_id } = {}) => {
try {
const cohort = await CohortModel(tenant).findById(cohort_id);
const request = {
query: {
cohort_id,
},
};
const filter = generateFilter.cohorts(request);

if (!cohort) {
const responseFromListCohort = await CohortModel(tenant).list({ filter });
logObject("responseFromListCohort.data[0]", responseFromListCohort.data[0]);
const cohortDetails = responseFromListCohort.data[0];

if (responseFromListCohort.data.length > 1 || isEmpty(cohortDetails)) {
return {
success: false,
message: "Bad Request Error",
errors: { message: "Cohort not found" },
errors: { message: "No distinct Cohort found in this search" },
status: httpStatus.BAD_REQUEST,
};
}
const assignedDevices = cohort.devices || [];
const deviceIds = assignedDevices.map((device) => device.toString());
const assignedDevices = cohortDetails.devices || [];
const deviceIds = assignedDevices.map((device) => device._id.toString());

const commaSeparatedIds = deviceIds.join(",");
logObject("commaSeparatedIds", commaSeparatedIds);

return {
success: true,
Expand Down Expand Up @@ -1769,7 +1792,10 @@ const createEvent = {
const status = responseFromGetDevicesOfCohort.status
? responseFromGetDevicesOfCohort.status
: httpStatus.OK;
return res.status(status).json(responseFromGetDevicesOfCohort);
return res.status(status).json({
success: true,
message: `The provided Cohort ID ${cohort_id} does not have any associated Device IDs`,
});
}
request.query.device_id = responseFromGetDevicesOfCohort.data;
}
Expand Down

0 comments on commit 58e0f4e

Please sign in to comment.