Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anissa-agahchen committed May 8, 2023
1 parent a3bbfec commit 6c83299
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/src/services/summary-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions api/src/services/validation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -397,7 +400,7 @@ export class ValidationService extends DBService {
async persistValidationResults(csvState: ICsvState[], mediaState: IMediaState): Promise<boolean> {
defaultLog.debug({ label: 'persistValidationResults', message: 'validationResults' });

let parseError = false;
const parseError = false;
const errors: MessageError[] = [];

mediaState.fileErrors?.forEach((fileError) => {
Expand Down Expand Up @@ -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 });
}

Expand Down
12 changes: 5 additions & 7 deletions api/src/utils/media/xlsx/transformation/xlsx-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -164,7 +164,7 @@ export class XLSXTransform {
return worksheetJSONWithKey;
}

_getKeyForRowObject(RowObject: Record<TemplateColumnName, any>, keyColumnNames: string[], rowNumber: number): string {
_getKeyForRowObject(RowObject: Record<TemplateColumnName, any>, keyColumnNames: string[]): string {
if (!keyColumnNames.length) {
return '';
}
Expand All @@ -178,9 +178,7 @@ export class XLSXTransform {
return RowObject[columnName];
})
.filter((value) => !isNaN || value)
.join(':')
.concat(':')
.concat(rowNumber.toString());
.join(':');

return primaryKey;
}
Expand Down

0 comments on commit 6c83299

Please sign in to comment.