Skip to content

Commit

Permalink
Merge pull request #703 from HDRUK/hotfix/v2.7.1
Browse files Browse the repository at this point in the history
Hotfix/v2.7.1
  • Loading branch information
pawilliams-hdr authored Mar 30, 2022
2 parents 903b191 + 7c7d376 commit 052a921
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/controllers/datasetonboarding.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/message/message.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
path: 'publisher',
populate: {
path: 'team',
select: 'members',
select: 'members notifications',
populate: {
path: 'users',
},
Expand Down
12 changes: 1 addition & 11 deletions src/resources/search/search.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions src/services/__mocks__/datasetSearchStub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
49 changes: 49 additions & 0 deletions src/services/__tests__/datasetonboarding.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
2 changes: 1 addition & 1 deletion src/services/datasetonboarding.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default class DatasetOnboardingService {
return data;
};

updateStructuralMetadata = async (structuralMetadata, id) => {
updateStructuralMetadata = async (structuralMetadata, percentageCompleted, id) => {
await Data.findByIdAndUpdate(
{ _id: id },
{
Expand Down

0 comments on commit 052a921

Please sign in to comment.