From 40fa0d7218f8c58bcb9c0072a5d6b45eca440c02 Mon Sep 17 00:00:00 2001 From: Alfred Rosenthal Date: Wed, 5 Jul 2023 13:21:01 -0600 Subject: [PATCH 1/4] fixed bug with admin dashboard --- api/src/services/submission-service.ts | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/api/src/services/submission-service.ts b/api/src/services/submission-service.ts index e97472a08..2f6bfa24f 100644 --- a/api/src/services/submission-service.ts +++ b/api/src/services/submission-service.ts @@ -451,11 +451,14 @@ export class SubmissionService extends DBService { const datasetsForReview: IDatasetsForReview[] = []; for await (const item of data) { + // total of all artifacts needing review let rollUpCount = 0; const dates: string[] = []; + // fetch artifact count for any related datasets if (item.related_projects) { for await (const rp of item.related_projects) { + console.log(rp['@_id']); const rpCount = await this.submissionRepository.getArtifactForReviewCountForSubmissionUUID(rp['@_id']); if (rpCount) { rollUpCount += rpCount.artifacts_to_review; @@ -464,25 +467,27 @@ export class SubmissionService extends DBService { } } + // fetch artifact count for primary datasets const parentArtifactCount = await this.submissionRepository.getArtifactForReviewCountForSubmissionUUID( item.dataset_id ); if (parentArtifactCount) { - const finalCount = rollUpCount + parentArtifactCount.artifacts_to_review; - - // only push projects with artifacts to review - if (finalCount > 0) { - dates.push(parentArtifactCount.last_updated ?? ''); - datasetsForReview.push({ - dataset_id: parentArtifactCount.dataset_id, - artifacts_to_review: finalCount, - dataset_name: item.dataset_name, - last_updated: this.mostRecentDate(dates), - keywords: item.keywords - }); - } + rollUpCount += parentArtifactCount.artifacts_to_review; + dates.push(parentArtifactCount.last_updated ?? ''); + } + + // only add to returned list if there are any artifacts for review + if (rollUpCount > 0) { + datasetsForReview.push({ + dataset_id: item.dataset_id, + artifacts_to_review: rollUpCount, + dataset_name: item.dataset_name, + last_updated: this.mostRecentDate(dates), + keywords: item.keywords + }); } } + return datasetsForReview; } From f4d17127aa6121523b17b72d9d1735da9f352060 Mon Sep 17 00:00:00 2001 From: Alfred Rosenthal Date: Mon, 17 Jul 2023 11:51:49 -0700 Subject: [PATCH 2/4] removed console log --- api/src/services/submission-service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/services/submission-service.ts b/api/src/services/submission-service.ts index 2f6bfa24f..74dd820c1 100644 --- a/api/src/services/submission-service.ts +++ b/api/src/services/submission-service.ts @@ -458,7 +458,6 @@ export class SubmissionService extends DBService { // fetch artifact count for any related datasets if (item.related_projects) { for await (const rp of item.related_projects) { - console.log(rp['@_id']); const rpCount = await this.submissionRepository.getArtifactForReviewCountForSubmissionUUID(rp['@_id']); if (rpCount) { rollUpCount += rpCount.artifacts_to_review; From f110c6ff9d6fceea25bc49caee4efc4cedba62ec Mon Sep 17 00:00:00 2001 From: Alfred Rosenthal Date: Mon, 17 Jul 2023 12:13:26 -0700 Subject: [PATCH 3/4] fixed test --- api/src/services/submission-service.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/services/submission-service.test.ts b/api/src/services/submission-service.test.ts index fc32c792f..79394cd70 100644 --- a/api/src/services/submission-service.test.ts +++ b/api/src/services/submission-service.test.ts @@ -649,21 +649,21 @@ describe('SubmissionService', () => { expect(stubArtifactCount).to.be.calledWith('RP_UUID_3'); expect(response).to.be.eql([ { - dataset_id: '', + dataset_id: 'UUID', artifacts_to_review: 1, dataset_name: 'Project Name', last_updated: '', keywords: [] }, { - dataset_id: '', + dataset_id: 'UUID', artifacts_to_review: 3, dataset_name: 'Project Name', last_updated: '', keywords: [] }, { - dataset_id: '', + dataset_id: 'UUID', artifacts_to_review: 2, dataset_name: 'Project Name', last_updated: '', From 82ebec2e4ed84a14351d1960b4beeb3b7af61d77 Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Mon, 4 Dec 2023 13:39:54 -0800 Subject: [PATCH 4/4] ignore-skip