Skip to content

Commit

Permalink
Merge pull request #496 from HDRUK/SUPP-643-hotfix
Browse files Browse the repository at this point in the history
SUPP-643 - DAR - Fixed issue with incorrectly reporting NHS Digital datasets as 5 safe
  • Loading branch information
RobinKavPA authored Sep 14, 2021
2 parents 2e4159d + cb05306 commit 87b1c0a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
33 changes: 33 additions & 0 deletions migrations/1631621029553-update_publishers_uses5safes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PublisherModel } from '../src/resources/publisher/publisher.model';

/**
* Make any changes you need to make to the database here
*/
async function up() {
// 1. Find all publishers
const publishers = await PublisherModel.find({ allowAccessRequestManagement: true, name: { $not : /.*ALLIANCE > NHS DIGITAL.*/i } }).lean();

let ops = [];

publishers.forEach(publisher => {
const { _id } = publisher;
ops.push({
updateOne: {
filter: { _id },
update: {
uses5Safes: true,
},
upsert: false,
},
});
});

await PublisherModel.bulkWrite(ops);
}

/**
* Make any changes that UNDO the up function side effects here (if possible)
*/
async function down() {}

module.exports = { up, down };
4 changes: 2 additions & 2 deletions src/resources/dataset/datasetonboarding.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ module.exports = {
data.type = 'dataset';
data.activeflag = 'draft';
data.source = 'HDRUK MDC';
data.is5Safes = publisherData[0].allowAccessRequestManagement;
data.is5Safes = publisherData[0].uses5Safes;
data.timestamps.created = Date.now();
data.timestamps.updated = Date.now();
data.questionAnswers = JSON.stringify({
Expand Down Expand Up @@ -206,7 +206,7 @@ module.exports = {
data.type = 'dataset';
data.activeflag = 'draft';
data.source = 'HDRUK MDC';
data.is5Safes = publisherData[0].allowAccessRequestManagement;
data.is5Safes = publisherData[0].uses5Safes;
data.questionAnswers = JSON.stringify(datasetToCopy.questionAnswers);
data.structuralMetadata = datasetToCopy.structuralMetadata;
data.percentageCompleted = datasetToCopy.percentageCompleted;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/dataset/v1/dataset.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ async function checkDifferentialValid(incomingMetadataCount, source, override) {
}

async function getDataAccessRequestCustodians() {
const publishers = await PublisherModel.find({ allowAccessRequestManagement: true }).select('name').lean();
const publishers = await PublisherModel.find({ allowAccessRequestManagement: true, uses5Safes: true }).select('name').lean();
return publishers.map(publisher => publisher.name);
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/publisher/publisher.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const PublisherSchema = new Schema(
rorOrgId: String,
gridAcId: String,
allowAccessRequestManagement: { type: Boolean, default: false },
uses5Safes: { type: Boolean, default: false },
},
{
toJSON: { virtuals: true },
Expand Down

0 comments on commit 87b1c0a

Please sign in to comment.