Skip to content

Commit

Permalink
2606/mecr (#1292)
Browse files Browse the repository at this point in the history
* wip

* Amend callable function interface

* merge

* fix-function

* fix-function

* fix-function

* fix-function

* fix-function

* add test

---------

Co-authored-by: warrensearle <warren@precise-minds.co.uk>
  • Loading branch information
tomlovesgithub and warrensearle authored Dec 24, 2024
1 parent cc8f3a9 commit 8f412af
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
4 changes: 1 addition & 3 deletions functions/actions/exercises/getMultipleApplicationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export default (config, firebase, db, auth) => {

const getApplicationData = initGetApplicationData(config, firebase, db, auth);

return getMultipleApplicationData;

return getMultipleApplicationData;
async function getMultipleApplicationData(exerciseIds, columns) {
const allData = [];

Expand All @@ -23,5 +22,4 @@ export default (config, firebase, db, auth) => {

return allData;
}

};
1 change: 1 addition & 0 deletions functions/callableFunctions/getMultipleApplicationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default functions.runWith(runtimeOptions).region('europe-west2').https.on
}, data)) {
throw new functions.https.HttpsError('invalid-argument', 'Please provide valid arguments');
}

return getMultipleApplicationData(data.exerciseIds, data.columns);

});
Expand Down
7 changes: 2 additions & 5 deletions nodeScripts/getMultipleApplicationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ const getMultipleApplicationData = initGetMultipleApplicationData(config, fireba
const exerciseIds = ['XvzIg48K9XOhfeFr3w91', 'Biyjd07Xz2usL9yXjtjV', 'IKLcf2Y187f2WTjifsoj'];

// Params for each call to getApplicationData
const params = {
columns: ['exerciseRef','referenceNumber','personalDetails.fullName','status'],
whereClauses: [],
};
const columns = ['exerciseRef','referenceNumber','personalDetails.fullName','status'];

const main = async () => {
return getMultipleApplicationData(exerciseIds, params);
return getMultipleApplicationData(exerciseIds, columns);
};

main()
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions test/functions/getMultipleApplicationData.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ describe('getMultipleApplicationData', () => {
context('Functionality', () => {
it('should return data for multiple exerciseIds', async () => {
const exerciseIds = ['exerciseId1', 'exerciseId2', 'exerciseId3'];
const params = {
statuses: ['status1', 'status2'],
columns: ['column1', 'column2'],
whereClauses: [],
type: 'data',
stage: 'stage1',
stageStatus: 'status',
};
const columns = ['exerciseRef','referenceNumber'];

const wrapped = wrap(getMultipleApplicationData);
const context = generateMockContext({
Expand All @@ -50,7 +43,7 @@ describe('getMultipleApplicationData', () => {
],
});

const result = await wrapped({ exerciseIds, params }, context);
const result = await wrapped({ exerciseIds, columns }, context);
assert(Array.isArray(result), 'Result should be an array');
assert(result.length > 0, 'Result should contain data');
});
Expand Down

0 comments on commit 8f412af

Please sign in to comment.