From 89d24f8e07e7b67217f536f30e8e28eef02d66c1 Mon Sep 17 00:00:00 2001 From: Dan Nita Date: Mon, 14 Mar 2022 09:48:03 +0000 Subject: [PATCH 1/3] update search algorithm --- src/resources/search/search.router.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/resources/search/search.router.js b/src/resources/search/search.router.js index cd8a461d..82bca413 100644 --- a/src/resources/search/search.router.js +++ b/src/resources/search/search.router.js @@ -29,17 +29,7 @@ router.get('/', async (req, res) => { let searchAll = false; if (searchString.length > 0) { - searchQuery['$and'].push({ $text: { $search: searchString } }); - - /* datasetSearchString = '"' + searchString.split(' ').join('""') + '"'; - //The following code is a workaround for the way search works TODO:work with MDC to improve API - if (searchString.match(/"/)) { - //user has added quotes so pass string through - datasetSearchString = searchString; - } else { - //no quotes so lets a proximiy search - datasetSearchString = '"'+searchString+'"~25'; - } */ + searchQuery['$and'].push({ $text: { $search: `'${searchString.split(" ").map(item => item.replace(/^/,"\"").replace(/$/,"\"")).join(" ")}'` }}); } else { searchAll = true; } From f46028717f7cc8f95b05accc501997429a59fbaa Mon Sep 17 00:00:00 2001 From: kandaj Date: Tue, 22 Mar 2022 16:13:54 +0000 Subject: [PATCH 2/3] update structural metadata --- .../datasetonboarding.controller.js | 2 +- src/services/__mocks__/datasetSearchStub.js | 16 ++++++ .../datasetonboarding.service.test.js | 49 +++++++++++++++++++ src/services/datasetonboarding.service.js | 2 +- 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/controllers/datasetonboarding.controller.js b/src/controllers/datasetonboarding.controller.js index 759a18ae..6a8ce5a7 100644 --- a/src/controllers/datasetonboarding.controller.js +++ b/src/controllers/datasetonboarding.controller.js @@ -158,7 +158,7 @@ export default class DatasetOnboardingController { if (isEmpty(structuralMetadata)) { return res.status(404).json({ status: 'error', message: 'Update failed' }); } else { - await this.datasetonboardingService.updateStructuralMetadata(structuralMetadata, id); + await this.datasetonboardingService.updateStructuralMetadata(structuralMetadata, data.percentageCompleted, id); return res.status(200).json(); } } diff --git a/src/services/__mocks__/datasetSearchStub.js b/src/services/__mocks__/datasetSearchStub.js index d5fc5d05..3e7460cb 100644 --- a/src/services/__mocks__/datasetSearchStub.js +++ b/src/services/__mocks__/datasetSearchStub.js @@ -78,6 +78,22 @@ export const datasetSearchStub = [ }, }, type: 'dataset', + structuralMetadata: [], + percentageCompleted: { + summary: 20, + documentation: 100, + coverage: 0, + origin: 0, + temporal: 0, + usage: 0, + access: 0, + formatAndStandards: 0, + enrichmentAndLinkage: 0, + observations: 0, + provenance: 0, + accessibility: 0, + structural: 0, + }, }, { _id: ObjectID('615aee882414847722e46ac5'), diff --git a/src/services/__tests__/datasetonboarding.service.test.js b/src/services/__tests__/datasetonboarding.service.test.js index f3327993..62bf39a9 100644 --- a/src/services/__tests__/datasetonboarding.service.test.js +++ b/src/services/__tests__/datasetonboarding.service.test.js @@ -283,4 +283,53 @@ describe('datasetOnboardingService', () => { expect(duplicatedDataset.datasetVersion).toEqual('1.0.0'); }); }); + + describe('updateStructuralMetadata', () => { + it('structuralMetadata should be empty for a dataset and percentageCompleted to be zero', async () => { + const dataset = datasetSearchStub[3]; + expect(dataset.structuralMetadata).toEqual([]); + expect(dataset.percentageCompleted.structural).toEqual(0); + }); + it('structuralMetadata should not be empty for a dataset and percentageCompleted to be 100 ', async () => { + const dataset = datasetSearchStub[3]; + const structuralMetadata = [ + { + tableName: 'PDR28DrugAdmin', + tableDescription: 'Drug Admin details for each spell', + columnName: 'drug_administration_id', + columnDescription: 'Unique identifier for the drug administration event', + dataType: 'varchar', + sensitive: false, + }, + { + tableName: 'PDR28DrugAdmin', + tableDescription: 'Drug Admin details for each spell', + columnName: 'patient_pseudo_id', + columnDescription: 'Hashed patient identification', + dataType: 'varchar', + sensitive: false, + }, + ]; + const percentageCompleted = { + summary: 20, + documentation: 100, + coverage: 0, + origin: 0, + temporal: 0, + usage: 0, + access: 0, + formatAndStandards: 0, + enrichmentAndLinkage: 0, + observations: 0, + provenance: 0, + accessibility: 0, + structural: 100, + }; + + await datasetonboardingService.updateStructuralMetadata(structuralMetadata, percentageCompleted, dataset._id); + const updatedDataset = await Data.findOne({ _id: dataset._id }); + expect(updatedDataset.structuralMetadata.length).toEqual(2); + expect(updatedDataset.percentageCompleted.structural).toEqual(100); + }); + }); }); diff --git a/src/services/datasetonboarding.service.js b/src/services/datasetonboarding.service.js index ec40ea23..54580148 100644 --- a/src/services/datasetonboarding.service.js +++ b/src/services/datasetonboarding.service.js @@ -363,7 +363,7 @@ export default class DatasetOnboardingService { return data; }; - updateStructuralMetadata = async (structuralMetadata, id) => { + updateStructuralMetadata = async (structuralMetadata, percentageCompleted, id) => { await Data.findByIdAndUpdate( { _id: id }, { From da301424591e4f4c8d1eb4cd5bd074cd528fe42a Mon Sep 17 00:00:00 2001 From: Callum Reekie Date: Thu, 24 Mar 2022 12:02:18 +0000 Subject: [PATCH 3/3] fix enquiry email bug --- src/resources/message/message.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/message/message.controller.js b/src/resources/message/message.controller.js index f45a32c3..a230e18a 100644 --- a/src/resources/message/message.controller.js +++ b/src/resources/message/message.controller.js @@ -30,7 +30,7 @@ module.exports = { path: 'publisher', populate: { path: 'team', - select: 'members', + select: 'members notifications', populate: { path: 'users', },