Skip to content

Commit

Permalink
Merge pull request #629 from episphere/stage
Browse files Browse the repository at this point in the history
Stage -> Prod Sync (July 2024 Release)
  • Loading branch information
we-ai authored Aug 1, 2024
2 parents c490697 + 5568847 commit de5e8ed
Show file tree
Hide file tree
Showing 17 changed files with 565 additions and 328 deletions.
4 changes: 4 additions & 0 deletions config/dev/cloudbuild1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ steps:
args: ['functions', 'deploy', 'biospecimen', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/dev/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'biospecimen', '--member=allUsers', '--role=${_ROLE}']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'deploy', 'heartbeat', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/dev/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'heartbeat', '--member=allUsers', '--role=${_ROLE}']
substitutions:
_SOURCE: https://source.developers.google.com/projects/nih-nci-dceg-connect-dev/repos/github_episphere_connectfaas/moveable-aliases/dev
_RUNTIME: nodejs20
Expand Down
4 changes: 4 additions & 0 deletions config/prod/cloudbuild1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ steps:
args: ['functions', 'deploy', 'biospecimen', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/prod/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'biospecimen', '--member=allUsers', '--role=${_ROLE}']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'deploy', 'heartbeat', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/prod/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'heartbeat', '--member=allUsers', '--role=${_ROLE}']
substitutions:
_SOURCE: https://source.developers.google.com/projects/nih-nci-dceg-connect-prod-6d04/repos/github_episphere_connectfaas
_RUNTIME: nodejs20
Expand Down
4 changes: 4 additions & 0 deletions config/stage/cloudbuild1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ steps:
args: ['functions', 'deploy', 'biospecimen', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/stage/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'biospecimen', '--member=allUsers', '--role=${_ROLE}']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'deploy', 'heartbeat', '--trigger-http', '--runtime=${_RUNTIME}', '--source=${_SOURCE}', '--env-vars-file=config/stage/.env.yaml']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'add-iam-policy-binding', 'heartbeat', '--member=allUsers', '--role=${_ROLE}']
substitutions:
_SOURCE: https://source.developers.google.com/projects/nih-nci-dceg-connect-stg-5519/repos/github_episphere_connectfaas/moveable-aliases/stage
_RUNTIME: nodejs20
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const { getToken } = require('./utils/validation');
const { getFilteredParticipants, getParticipants, identifyParticipant } = require('./utils/submission');
const { submitParticipantsData, updateParticipantData } = require('./utils/sites');
const { sendScheduledNotifications } = require('./utils/notifications');
const { getParticipantNotification, sendScheduledNotifications } = require('./utils/notifications');
const { connectApp } = require('./utils/connectApp');
const { biospecimenAPIs } = require('./utils/biospecimen');
const { incentiveCompleted, eligibleForIncentive } = require('./utils/incentive');
const { dashboard } = require('./utils/dashboard');
const { getParticipantNotification } = require('./utils/notifications');
const { importToBigQuery, firestoreExport, exportNotificationsToBucket, importNotificationsToBigquery } = require('./utils/events');
const { participantDataCleanup } = require('./utils/participantDataCleanup');
const { webhook } = require('./utils/webhook');
const { heartbeat } = require('./utils/heartbeat');

// API End-Points for Sites

Expand Down Expand Up @@ -68,4 +68,8 @@ exports.participantDataCleanup = participantDataCleanup;

// End-Points for Event Webhook

exports.webhook = webhook;
exports.webhook = webhook;

// End-Points for Public Heartbeat

exports.heartbeat = heartbeat;
13 changes: 7 additions & 6 deletions utils/biospecimen.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { getResponseJSON, setHeaders, logIPAdddress, SSOValidation, convertSiteLoginToNumber } = require('./shared');
const { getResponseJSON, setHeaders, logIPAddress, SSOValidation, convertSiteLoginToNumber } = require('./shared');
const fieldMapping = require('./fieldToConceptIdMapping');
const { sendInstantNotification } = require("./notifications");

const biospecimenAPIs = async (req, res) => {
logIPAdddress(req);
logIPAddress(req);
setHeaders(res);

if(req.method === 'OPTIONS') return res.status(200).json({code: 200});
Expand Down Expand Up @@ -671,13 +671,14 @@ const biospecimenAPIs = async (req, res) => {
if( req.method !== 'GET') {
return res.status(405).json(getResponseJSON('Only GET requests are accepted!', 405));
}
const supplyQuery = req.query.supplyKitId;
const collectionQuery = (req.query.collectionId?.slice(0, -4) || "") + " " + (req.query.collectionId?.slice(-4) || ""); // add space to collection
const supplyKitId = req.query.supplyKitId;
const collectionIdSuffix = (req.query.collectionId?.slice(0, -4) || "") + " " + (req.query.collectionId?.slice(-4) || ""); // add space to collection
const returnKitTrackingNumberNumber = req.query.returnKitTrackingNumber;
if (Object.keys(query).length === 0) return res.status(404).json(getResponseJSON('Please include id to check uniqueness.', 400));
if (collectionQuery.length < 14) return res.status(200).json({data: 'Check Collection ID', code:200});
if (collectionIdSuffix.length < 14) return res.status(200).json({data: 'Check Collection ID', code:200});
try {
const { checkCollectionUniqueness } = require('./firestore');
const response = await checkCollectionUniqueness(supplyQuery, collectionQuery);
const response = await checkCollectionUniqueness(supplyKitId, collectionIdSuffix, returnKitTrackingNumberNumber);
return res.status(200).json({data: response, code:200});
}
catch (error) {
Expand Down
42 changes: 40 additions & 2 deletions utils/connectApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const connectApp = async (req, res) => {
return res.status(405).json(getResponseJSON('Only GET requests are accepted!', 405));
}

if (!req.query.path || req.query.path === '') {
if (!req.query.path) {
return res.status(400).json(getResponseJSON('Path parameter is required!', 400));
}

Expand All @@ -73,12 +73,34 @@ const connectApp = async (req, res) => {

return res.status(200).json({data: shaResult, code: 200});
}

else if (api === 'getQuestSurveyFromGitHub') {
if (req.method !== 'GET') {
return res.status(405).json(getResponseJSON('Only GET requests are accepted!', 405));
}

const { sha, path } = req.query;

if (!sha) {
return res.status(400).json(getResponseJSON('Sha parameter is required!', 400));
}

if (!path) {
return res.status(400).json(getResponseJSON('Path parameter is required!', 400));
}

const { getQuestSurveyFromGitHub } = require('./submission');
const moduleTextAndVersionResult = await getQuestSurveyFromGitHub(sha, path);

return res.status(200).json({data: moduleTextAndVersionResult, code: 200});
}

else if (api === 'getSHAFromGitHubCommitData') {
if (req.method !== 'GET') {
return res.status(405).json(getResponseJSON('Only GET requests are accepted!', 405));
}

if (!req.query.path || req.query.path === '') {
if (!req.query.path) {
return res.status(400).json(getResponseJSON('Path parameter is required!', 400));
}

Expand All @@ -91,6 +113,22 @@ const connectApp = async (req, res) => {
return res.status(200).json({data: shaResult, code: 200});
}

else if (api === 'getAppSettings') {
if (req.method !== 'GET') {
return res.status(405).json(getResponseJSON('Only GET requests are accepted!', 405));
}

const selectedParamsArray = req.query.selectedParamsArray?.split(',');
if (!selectedParamsArray || !Array.isArray(selectedParamsArray) || selectedParamsArray.length === 0) {
return res.status(400).json(getResponseJSON("Error: selectedParamsArray is required. Please specify parameters to return.", 400));
}

const { getAppSettings } = require('./firestore');
const appSettings = await getAppSettings('connectApp', selectedParamsArray);

return res.status(200).json({data: appSettings, code: 200});
}

else return res.status(400).json(getResponseJSON('Bad request!', 400));

} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions utils/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { getResponseJSON, setHeaders, logIPAdddress } = require('./shared');
const { getResponseJSON, setHeaders, logIPAddress } = require('./shared');

const dashboard = async (req, res) => {
logIPAdddress(req);
logIPAddress(req);
setHeaders(res);
if (req.method === 'OPTIONS') return res.status(200).json({code: 200});
if (!req.headers.authorization || req.headers.authorization.trim() === "") {
Expand Down
4 changes: 3 additions & 1 deletion utils/fieldToConceptIdMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ module.exports = {
baselineBloodAndUrineIsRefused: 526455436,
baselineMouthwashCollected: 684635302,
baselineBloodSampleCollected: 878865966,
bioSpmVisitV1r0: 331584571
bioSpmVisitV1r0: 331584571,
allBaselineSurveysCompleted: 100767870,
firebaseAuthenticationEmail: 421823980,
}
};
Loading

0 comments on commit de5e8ed

Please sign in to comment.