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

Bugfix: Admin Dashboard #208

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 3 additions & 3 deletions api/src/services/submission-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,21 +646,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: '',
Expand Down
30 changes: 17 additions & 13 deletions api/src/services/submission-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,11 @@ 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) {
const rpCount = await this.submissionRepository.getArtifactForReviewCountForSubmissionUUID(rp['@_id']);
Expand All @@ -489,25 +491,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;
}

Expand Down
Loading