-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1536 from SciCatProject/migrate-principal-investi…
…gator feat: migrate dataset principalInvestigator to principalInvestigators
- Loading branch information
Showing
7 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
migrations/20241202105905-multiple-principal-investigators.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
async up(db, client) { | ||
await db.collection("Dataset").updateMany({}, [ | ||
{ | ||
$set: { | ||
principalInvestigators: ["$principalInvestigator"], | ||
}, | ||
}, | ||
]); | ||
|
||
await db | ||
.collection("Dataset") | ||
.updateMany({}, { $unset: { principalInvestigator: "" } }); | ||
}, | ||
|
||
async down(db, client) { | ||
await db.collection("Dataset").updateMany({}, [ | ||
{ | ||
$set: { | ||
principalInvestigator: { | ||
$arrayElemAt: ["$principalInvestigators", 0], | ||
}, | ||
}, | ||
}, | ||
]); | ||
|
||
await db | ||
.collection("Dataset") | ||
.updateMany({}, { $unset: { principalInvestigators: "" } }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ const mockDataset: DatasetClass = { | |
pid: "testPid", | ||
owner: "testOwner", | ||
ownerEmail: "[email protected]", | ||
instrumentId: "testInstrumentId", | ||
instrumentIds: ["testInstrumentId"], | ||
orcidOfOwner: "https://0000.0000.0000.0001", | ||
contactEmail: "[email protected]", | ||
sourceFolder: "/nfs/groups/beamlines/test/123456", | ||
|
@@ -59,24 +59,20 @@ const mockDataset: DatasetClass = { | |
createdAt: new Date("2021-11-11T12:29:02.083Z"), | ||
updatedAt: new Date("2021-11-11T12:29:02.083Z"), | ||
techniques: [], | ||
principalInvestigator: "testInvestigator", | ||
principalInvestigators: ["testInvestigator"], | ||
endTime: new Date("2021-12-11T12:29:02.083Z"), | ||
creationLocation: "test", | ||
dataFormat: "Test Format", | ||
scientificMetadata: {}, | ||
proposalId: "ABCDEF", | ||
sampleId: "testSampleId", | ||
attachments: [], | ||
proposalIds: ["ABCDEF"], | ||
sampleIds: ["testSampleId"], | ||
accessGroups: [], | ||
createdBy: "test user", | ||
datablocks: [], | ||
origdatablocks: [], | ||
ownerGroup: "test", | ||
relationships: [], | ||
sharedWith: [], | ||
updatedBy: "test", | ||
instrumentGroup: "test", | ||
investigator: "test", | ||
inputDatasets: [], | ||
usedSoftware: [], | ||
jobParameters: {}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,7 +481,7 @@ const TestData = { | |
}, | ||
|
||
CustomDatasetCorrectMin: { | ||
principalInvestigator: faker.internet.email(), | ||
principalInvestigators: [faker.internet.email()], | ||
owner: faker.internet.username(), | ||
contactEmail: faker.internet.email(), | ||
sourceFolder: faker.system.directoryPath(), | ||
|
@@ -492,7 +492,7 @@ const TestData = { | |
}, | ||
|
||
CustomDatasetCorrect: { | ||
principalInvestigator: "[email protected]", | ||
principalInvestigators: ["[email protected]"], | ||
inputDatasets: ["/data/input/file1.dat"], | ||
usedSoftware: [ | ||
"https://gitlab.psi.ch/ANALYSIS/csaxs/commit/7d5888bfffc440bb613bc7fa50adc0097853446c", | ||
|
@@ -522,7 +522,7 @@ const TestData = { | |
}, | ||
|
||
CustomDatasetWrongType: { | ||
principalInvestigator: "[email protected]", | ||
principalInvestigators: ["[email protected]"], | ||
jobParameters: { | ||
nscans: 10, | ||
}, | ||
|
@@ -540,7 +540,7 @@ const TestData = { | |
}, | ||
|
||
CustomDatasetWrongData: { | ||
principalInvestigator: "[email protected]", | ||
principalInvestigators: ["[email protected]"], | ||
jobParameters: { | ||
nscans: 10, | ||
}, | ||
|
@@ -559,7 +559,7 @@ const TestData = { | |
}, | ||
|
||
CustomDatasetIncompleteData: { | ||
principalInvestigator: "[email protected]", | ||
principalInvestigators: ["[email protected]"], | ||
jobParameters: { | ||
nscans: 10, | ||
}, | ||
|