diff --git a/api/src/services/summary-service.ts b/api/src/services/summary-service.ts index d9fdc7e698..bed92ff4e1 100644 --- a/api/src/services/summary-service.ts +++ b/api/src/services/summary-service.ts @@ -308,7 +308,7 @@ export class SummaryService extends DBService { const media_state = file.getMediaState(); if (!media_state.isValid) { - return { csv_state: ([] as unknown) as ICsvState[], media_state }; + return { csv_state: [], media_state }; } // Run CSV content validations diff --git a/api/src/services/validation-service.ts b/api/src/services/validation-service.ts index 5460127e04..9261e90a3d 100644 --- a/api/src/services/validation-service.ts +++ b/api/src/services/validation-service.ts @@ -366,7 +366,10 @@ export class ValidationService extends DBService { const media_state = file.getMediaState(); if (!media_state.isValid) { - return { csv_state: ([] as unknown) as ICsvState[], media_state }; + return { + csv_state: [], + media_state + }; } file.validateContent(parser); @@ -397,7 +400,7 @@ export class ValidationService extends DBService { async persistValidationResults(csvState: ICsvState[], mediaState: IMediaState): Promise { defaultLog.debug({ label: 'persistValidationResults', message: 'validationResults' }); - let parseError = false; + const parseError = false; const errors: MessageError[] = []; mediaState.fileErrors?.forEach((fileError) => { @@ -440,10 +443,6 @@ export class ValidationService extends DBService { if (!mediaState.isValid || csvState?.some((item) => !item.isValid)) { // At least 1 error exists, skip remaining steps - parseError = true; - } - - if (parseError) { throw new SubmissionError({ messages: errors }); } diff --git a/api/src/utils/media/xlsx/transformation/xlsx-transform.ts b/api/src/utils/media/xlsx/transformation/xlsx-transform.ts index 40c078e370..6d8d48766c 100644 --- a/api/src/utils/media/xlsx/transformation/xlsx-transform.ts +++ b/api/src/utils/media/xlsx/transformation/xlsx-transform.ts @@ -135,17 +135,17 @@ export class XLSXTransform { const worksheetJSONWithKey: RowObject[] = []; for (let i = 0; i < numberOfRows; i++) { - const primaryKey = this._getKeyForRowObject(worksheetJSON[i], templateMetaSchema.primaryKey, i); + const primaryKey = this._getKeyForRowObject(worksheetJSON[i], templateMetaSchema.primaryKey); if (!primaryKey) { continue; } - const parentKey = this._getKeyForRowObject(worksheetJSON[i], templateMetaSchema.parentKey, i); + const parentKey = this._getKeyForRowObject(worksheetJSON[i], templateMetaSchema.parentKey); const childKeys = templateMetaSchema.foreignKeys .map((foreignKeys: { sheetName: TemplateColumnName; primaryKey: string[] }) => { - return this._getKeyForRowObject(worksheetJSON[i], foreignKeys.primaryKey, i); + return this._getKeyForRowObject(worksheetJSON[i], foreignKeys.primaryKey); }) .filter((item): item is string => !!item); @@ -164,7 +164,7 @@ export class XLSXTransform { return worksheetJSONWithKey; } - _getKeyForRowObject(RowObject: Record, keyColumnNames: string[], rowNumber: number): string { + _getKeyForRowObject(RowObject: Record, keyColumnNames: string[]): string { if (!keyColumnNames.length) { return ''; } @@ -178,9 +178,7 @@ export class XLSXTransform { return RowObject[columnName]; }) .filter((value) => !isNaN || value) - .join(':') - .concat(':') - .concat(rowNumber.toString()); + .join(':'); return primaryKey; }