Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to using datasetList in jobParams #1616

Open
wants to merge 1 commit into
base: release-jobs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/app/datasets/admin-tab/admin-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,19 @@ export class AdminTabComponent implements OnInit, OnDestroy {
job.createdBy = user.username;
job.createdAt = new Date();
job.type = "reset";
job.jobParams = {};
job.jobParams["datasetIds"] = [this.dataset["pid"]];
const fileList: string[] = [];
if (this.dataset["datablocks"]) {
this.dataset["datablocks"].map((d) => {
fileList.push(d["archiveId"]);
});
}
const fileObj: FileObject = {
pid: this.dataset["pid"],
files: fileList,
};
job.jobParams = {
datasetList: [fileObj]
};
console.log(job);
this.store.dispatch(submitJobAction({ job }));
}
Expand Down
14 changes: 10 additions & 4 deletions src/app/datasets/archiving.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ describe("ArchivingService", () => {
it("should create a new object of type Job", () => {
const user = new User({ username: "testName", email: "[email protected]" });
const datasets = [new Dataset()];
const datasetList = datasets.map((dataset) => dataset.pid);
const datasetList = datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
}));
const archive = true;
const destinationPath = { destinationPath: "/test/path/" };

Expand All @@ -61,7 +64,7 @@ describe("ArchivingService", () => {

expect(job).toBeInstanceOf(Job);
expect(job["createdBy"]).toEqual("testName");
expect(job["jobParams"]["datasetIds"]).toEqual(datasetList);
expect(job["jobParams"]["datasetList"]).toEqual(datasetList);
expect(job["type"]).toEqual("archive");
});
});
Expand All @@ -81,10 +84,13 @@ describe("ArchivingService", () => {

const user = new User({ username: "testName", email: "[email protected]" });
const datasets = [new Dataset()];
const datasetList = datasets.map((dataset) => dataset.pid);
const datasetList = datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
}));
const archive = true;
const job = new Job({
jobParams: { datasetIds: datasetList },
jobParams: { datasetList: datasetList },
createdBy: user.username,
createdAt: new Date(),
type: "archive",
Expand Down
7 changes: 4 additions & 3 deletions src/app/datasets/archiving.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class ArchivingService {
): Job {
const extra = archive ? {} : destinationPath;
const jobParams = {
datasetIds: datasets.map((dataset) => dataset.pid),
datasetList: datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
})),
...extra,
};

Expand All @@ -37,8 +40,6 @@ export class ArchivingService {

const data = {
jobParams,
createdBy: user.username,
// Revise this, files == []...? See earlier version of this method in dataset-table component for context
type: archive ? "archive" : "retrieve",
};

Expand Down
8 changes: 6 additions & 2 deletions src/app/datasets/datafiles/datafiles.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ export class DatafilesComponent
});
dialogRef.afterClosed().subscribe((email) => {
if (email) {
this.getSelectedFiles();
const data = {
createdBy: email,
createdAt: new Date(),
type: "public",
jobParams: {
datasetIds: [this.datasetPid],
datasetList: [
{
pid: this.datasetPid,
files: this.getSelectedFiles(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Store result of getSelectedFiles() in a variable

To avoid potential multiple calls to getSelectedFiles(), consider storing its result in a variable before using it in the job parameters.

const selectedFiles = this.getSelectedFiles();
datasetList: [
  {
    pid: this.datasetPid,
    files: selectedFiles,
  },
],

},
],
},
};
const job = new Job(data);
Expand Down
2 changes: 1 addition & 1 deletion src/app/state-management/effects/jobs.effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const data: JobInterface = {
createdBy: "testName",
type: "archive",
jobParams: {
datasetIds: [],
datasetList: [],
},
};
const job = new Job(data);
Expand Down
2 changes: 1 addition & 1 deletion src/app/state-management/reducers/jobs.reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const data: JobInterface = {
createdBy: "testName",
type: "archive",
jobParams: {
datasetIds: [],
datasetList: [],
},
};
const job = new Job(data);
Expand Down
2 changes: 1 addition & 1 deletion src/app/state-management/selectors/jobs.selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const data: JobInterface = {
createdBy: "testName",
type: "archive",
jobParams: {
datasetIds: [],
datasetList: [],
},
};
const job = new Job(data);
Expand Down