Skip to content

Commit

Permalink
Merge branch 'staging' into en-data-download
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnoble-19 committed Oct 23, 2024
2 parents 704f93e + 7986491 commit 576d9b2
Show file tree
Hide file tree
Showing 53 changed files with 5,464 additions and 3,327 deletions.
1 change: 0 additions & 1 deletion k8s/analytics/templates/devices-summary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
schedule: "0 4 * * *" # Every day at 4am
suspend: false
jobTemplate:
metadata:
name: {{ .Values.jobs.devicesSummaryJob.name }}
Expand Down
1 change: 0 additions & 1 deletion k8s/analytics/templates/reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
schedule: "0 0 1 */3 *" # Once every 3 months
suspend: false
jobTemplate:
metadata:
name: {{ .Values.jobs.reports.name }}
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-af858a91-1726240603
tag: prod-ee1694e7-1729615841
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-567f6c49-1726156795
tag: stage-0014fe93-1729266910
api:
name: airqo-stage-analytics-api
label: sta-alytics-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-b1ae309f-1729115553
tag: prod-ee1694e7-1729615841
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-745d8f2c-1729115369
tag: stage-6631dc02-1729615305
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-91285106-1729093394
tag: prod-ee1694e7-1729615841
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/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-device-registry-api
tag: stage-3e742d87-1728971657
tag: stage-52086ef0-1729584812
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-b1ae309f-1729115553
tag: prod-ee1694e7-1729615841
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-b1ae309f-1729115553
tag: prod-65aa1824-1729615373
nameOverride: ''
fullnameOverride: ''
1 change: 0 additions & 1 deletion k8s/predict/templates/places-airquality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ spec:
failedJobsHistoryLimit: 2
startingDeadlineSeconds: 1200
schedule: '{{ .Values.jobs.predictPlaces.schedule }}'
suspend: false
jobTemplate:
metadata:
name: {{ .Values.jobs.predictPlaces.name }}
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-b1ae309f-1729115553
tag: prod-ee1694e7-1729615841
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/predict/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ images:
predictJob: eu.gcr.io/airqo-250220/stage-airqo-predict-job
trainJob: eu.gcr.io/airqo-250220/stage-airqo-train-job
predictPlaces: eu.gcr.io/airqo-250220/stage-airqo-predict-places-air-quality
tag: stage-567f6c49-1726156795
tag: stage-0014fe93-1729266910
api:
name: airqo-stage-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-b1ae309f-1729115553
tag: prod-ee1694e7-1729615841
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-b8c3716f-1728774045
tag: prod-ee1694e7-1729615841
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-stage.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-stage-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-stage-redis
containers: eu.gcr.io/airqo-250220/airqo-stage-workflows
tag: stage-276bf9d4-1728654677
tag: stage-143b27ed-1729615802
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
4 changes: 3 additions & 1 deletion src/auth-service/bin/jobs/preferences-log-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const logUserPreferences = async () => {
}

// Log the aggregated results once after processing all users
if (totalUsersProcessed > 0) {
if (totalUsersProcessed > 0 && totalCountWithoutSelectedSites > 0) {
const percentageWithoutSelectedSites = (
(totalCountWithoutSelectedSites / totalUsersProcessed) *
100
Expand All @@ -63,6 +63,8 @@ const logUserPreferences = async () => {
logger.info(
`💔💔 Total count of users without any Customised Locations: ${totalCountWithoutSelectedSites}, which is ${percentageWithoutSelectedSites}% of all Analytics users.`
);
} else {
logger.info(`😎🎉✅ All Analytics users have Customised Locations.`);
}
} catch (error) {
logger.error(`🐛🐛 Error in logUserPreferences: ${stringify(error)}`);
Expand Down
20 changes: 10 additions & 10 deletions src/auth-service/bin/jobs/preferences-update-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ const updatePreferences = async (siteSelectionMethod = "featured") => {
selected_sites: selectedSites,
})
.catch((error) => {
logger.error(
`🐛🐛 Failed to create preference for user ${userIdStr}: ${stringify(
error
)}`
);
// logger.error(
// `🐛🐛 Failed to create preference for user ${userIdStr}: ${stringify(
// error
// )}`
// );
});
} else if (isEmpty(preference.selected_sites)) {
// Preference exists but selected_sites is empty, update it
Expand All @@ -132,11 +132,11 @@ const updatePreferences = async (siteSelectionMethod = "featured") => {
{ new: true }
)
.catch((error) => {
logger.error(
`🐛🐛 Failed to update preference for user ${userIdStr}: ${stringify(
error
)}`
);
// logger.error(
// `🐛🐛 Failed to update preference for user ${userIdStr}: ${stringify(
// error
// )}`
// );
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/auth-service/bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ app.use(function (err, req, res, next) {
logger.error(`🐛🐛 Internal Server Error --- ${stringify(err)}`);
logObject("Internal Server Error", err);
logger.error(`Stack Trace: ${err.stack}`);
res.status(err.status || 500).json({
res.status(err.status || err.statusCode || 500).json({
success: false,
message: "Internal Server Error - app entry",
message: "Internal Server Error",
errors: { message: err.message },
});
}
Expand Down
57 changes: 57 additions & 0 deletions src/auth-service/middleware/test/ut_setDefaultTenant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require("module-alias/register");
const { expect } = require("chai");
const sinon = require("sinon");
const setDefaultTenant = require("@middleware/setDefaultTenant");
const constants = require("@config/constants");

describe("setDefaultTenant Middleware", () => {
let req, res, next;

beforeEach(() => {
req = {
query: {},
};
res = {};
next = sinon.stub();
});

afterEach(() => {
sinon.restore(); // Restore the original functionality of stubbed methods
});

it("should set the default tenant if tenant is empty", () => {
// Set up the constant for testing
constants.DEFAULT_TENANT = "defaultTenant";

const middleware = setDefaultTenant;
middleware(req, res, next);

expect(req.query.tenant).to.equal("defaultTenant");
expect(next.calledOnce).to.be.true; // Ensure next() is called
});

it("should keep the existing tenant if provided", () => {
req.query.tenant = "customTenant";

const middleware = setDefaultTenant;
middleware(req, res, next);

expect(req.query.tenant).to.equal("customTenant");
expect(next.calledOnce).to.be.true; // Ensure next() is called
});

it("should use 'airqo' as the default tenant if no constant is defined", () => {
// Temporarily remove DEFAULT_TENANT for this test
const originalDefaultTenant = constants.DEFAULT_TENANT;
delete constants.DEFAULT_TENANT;

const middleware = setDefaultTenant;
middleware(req, res, next);

expect(req.query.tenant).to.equal("airqo");
expect(next.calledOnce).to.be.true; // Ensure next() is called

// Restore the original constant value after test
constants.DEFAULT_TENANT = originalDefaultTenant;
});
});
Loading

0 comments on commit 576d9b2

Please sign in to comment.