From 50eae5beed092de870a96e4a866a28ebb9e2a0db Mon Sep 17 00:00:00 2001 From: vmanawat Date: Tue, 28 Jan 2025 14:45:26 -0800 Subject: [PATCH 1/2] Reverting activity name for vertical profiles --- .../file_parse_and_validation.service.ts | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/backend/src/file_parse_and_validation/file_parse_and_validation.service.ts b/backend/src/file_parse_and_validation/file_parse_and_validation.service.ts index b44531d..1dee160 100644 --- a/backend/src/file_parse_and_validation/file_parse_and_validation.service.ts +++ b/backend/src/file_parse_and_validation/file_parse_and_validation.service.ts @@ -609,10 +609,15 @@ export class FileParseValidateService { const methodId = lookupResult.method_id; const methodContext = lookupResult.method_context; const methodName = lookupResult.method_name; - - const concatAnalysisMethod = String(methodId) + ';' + String(methodName) + ';' + String(methodContext); + + const concatAnalysisMethod = + String(methodId) + + ";" + + String(methodName) + + ";" + + String(methodContext); // Add quotes around the newAnalysisMethod only if it isn't already enclosed in quotes - newObs["Lab: Analysis Method"] = concatAnalysisMethod + newObs["Lab: Analysis Method"] = concatAnalysisMethod; } } @@ -1292,12 +1297,13 @@ export class FileParseValidateService { ministryContacts.add(fieldVisit.MinistryContact); // getting the ministry contacts (this will result in a unique list at the end of all rows) - if ( - rowData.DataClassification == "VERTICAL_PROFILE" || - rowData.DataClassification == "FIELD_RESULT" - ) { + if (rowData.DataClassification == "VERTICAL_PROFILE") { rowData.SpecimenName = ""; - rowData.ActivityName = ""; + } + + if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this + rowData.SpecimenName = ""; + rowData.ActivityName == ""; } const observation = this.filterFile( @@ -1312,13 +1318,12 @@ export class FileParseValidateService { rowNumber, ); - const csvRow = Object.values(obsRecord) + const csvRow = Object.values(obsRecord); - csvStream.write(csvRow) + csvStream.write(csvRow); this.logger.log(`Created observation object for row ${rowNumber}`); - this.logger.log( `Wrote observation object to file for row ${rowNumber}`, ); @@ -1445,8 +1450,14 @@ export class FileParseValidateService { const rowData: Record = rowHeaders .map((header, colNumber) => { const cellValue = row.getCell(colNumber + 1).value; // using getCell to access value with a 1-based index pattern + const value = + typeof cellValue === "object" && + cellValue != null && + "result" in cellValue + ? cellValue.result + : cellValue ?? ""; return { - [header]: String(cellValue ?? ""), + [header]: String(value), }; }) .reduce((acc, curr) => ({ ...acc, ...curr }), {}); @@ -1480,10 +1491,11 @@ export class FileParseValidateService { null, ); - if ( - rowData.DataClassification == "VERTICAL_PROFILE" || - rowData.DataClassification == "FIELD_RESULT" - ) { + if (rowData.DataClassification == "VERTICAL_PROFILE") { + specimen.SpecimenName = ""; + } + + if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this specimen.SpecimenName = ""; fieldActivity.ActivityName == ""; } @@ -2055,10 +2067,11 @@ export class FileParseValidateService { null, ); - if ( - rowData.DataClassification == "VERTICAL_PROFILE" || - rowData.DataClassification == "FIELD_RESULT" - ) { + if (rowData.DataClassification == "VERTICAL_PROFILE") { + specimen.SpecimenName = ""; + } + + if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this specimen.SpecimenName = ""; fieldActivity.ActivityName == ""; } From aaccc19b361770662f2ddab41b095a23afbe0015 Mon Sep 17 00:00:00 2001 From: vmanawat Date: Tue, 28 Jan 2025 15:27:24 -0800 Subject: [PATCH 2/2] Adding deletion status --- backend/src/aqi_api/aqi_api.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/aqi_api/aqi_api.service.ts b/backend/src/aqi_api/aqi_api.service.ts index d10437b..345f299 100644 --- a/backend/src/aqi_api/aqi_api.service.ts +++ b/backend/src/aqi_api/aqi_api.service.ts @@ -620,7 +620,7 @@ export class AqiApiService { }, }, ); - this.logger.log("AQI SPECIMEN DELETION: " + aqiDeletion.data); + this.logger.log("AQI SPECIMEN DELETION: " + aqiDeletion.status); try { const dbDeletion = await this.prisma.aqi_specimens.delete({ @@ -659,7 +659,7 @@ export class AqiApiService { }, }, ); - this.logger.log("AQI ACTIVITY DELETION: " + aqiDeletion.data); + this.logger.log("AQI ACTIVITY DELETION: " + aqiDeletion.status); try { const dbDeletion = await this.prisma.aqi_field_activities.delete({ @@ -698,7 +698,7 @@ export class AqiApiService { }, }, ); - this.logger.log("AQI VISIT DELETION: " + deletion.data); + this.logger.log("AQI VISIT DELETION: " + deletion.status); try { const dbDeletion = await this.prisma.aqi_field_visits.delete({