From 9b1f0562f59123f92501440868d943bcb58228ef Mon Sep 17 00:00:00 2001 From: knockknockyoo Date: Thu, 14 Nov 2024 10:17:59 -0500 Subject: [PATCH] submissionStats API - update origin property: "API: submissionStats" --- services/qc-result-service.js | 11 +++++++---- services/submission.js | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/services/qc-result-service.js b/services/qc-result-service.js index 9f8a1f74..116de1dd 100644 --- a/services/qc-result-service.js +++ b/services/qc-result-service.js @@ -131,7 +131,7 @@ class QcResultService{ record.error.title, replaceErrorString(record.error.desc, `'${record.fileName}'`) ); - return QCResult.create(VALIDATION.TYPES.DATA_FILE, VALIDATION.TYPES.DATA_FILE, record.fileName, null, null, VALIDATION_STATUS.ERROR, getCurrentTime(), getCurrentTime(), [errorMsg], [], record.dataRecordID); + return QCResult.create(VALIDATION.TYPES.DATA_FILE, VALIDATION.TYPES.DATA_FILE, record.fileName, null, null, VALIDATION_STATUS.ERROR, getCurrentTime(), getCurrentTime(), [errorMsg], [], record.dataRecordID, record?.origin); }); await Promise.all(qcResultErrors.map(async (qcResult) => { @@ -153,7 +153,7 @@ class QcResultService{ } class QCResult { - constructor(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID) { + constructor(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID, origin) { this.type = type; this.validationType = validationType; this.submittedID = submittedID; @@ -165,10 +165,13 @@ class QCResult { this.errors = errors || []; this.warnings = warnings || []; this.dataRecordID = dataRecordID; + if (origin) { + this.origin = origin; + } } - static create(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID) { - return new QCResult(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID); + static create(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID, origin) { + return new QCResult(type, validationType, submittedID, batchID, displayID, severity, uploadedDate, validatedDate, errors, warnings, dataRecordID, origin); } } diff --git a/services/submission.js b/services/submission.js index 9e67636a..188ed1a5 100644 --- a/services/submission.js +++ b/services/submission.js @@ -7,7 +7,6 @@ const {getCurrentTime, subtractDaysFromNow} = require("../crdc-datahub-database- const {HistoryEventBuilder} = require("../domain/history-event"); const {verifySession, verifySubmitter} = require("../verifier/user-info-verifier"); const {verifySubmissionAction} = require("../verifier/submission-verifier"); -const {getSortDirection} = require("../crdc-datahub-database-drivers/utility/mongodb-utility"); const {formatName} = require("../utility/format-name"); const ERROR = require("../constants/error-constants"); const USER_CONSTANTS = require("../crdc-datahub-database-drivers/constants/user-constants"); @@ -41,6 +40,7 @@ const FINAL_INACTIVE_REMINDER = "finalInactiveReminder"; const SUBMISSION_ID = "Submission ID"; const DATA_SUBMISSION_TYPE = "Data Submission Type"; const DESTINATION_LOCATION = "Destination Location"; +const SUBMISSION_STATS_ORIGIN_API = "API: submissionStats"; // Set to array Set.prototype.toArray = function() { return Array.from(this); @@ -1275,6 +1275,7 @@ class Submission { .filter(fileName => !qcResultFileNames.has(fileName)) .map(fileName => ({ fileName, + origin: SUBMISSION_STATS_ORIGIN_API, dataRecordID: null, error: { title: ERROR.MISSING_DATA_NODE_FILE_TITLE,