Skip to content

Commit cbeb206

Browse files
committed
Logs for Debugging the issue
1 parent 05221f2 commit cbeb206

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/cohort/cohort.service.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,21 @@ export class CohortService {
11201120
APIID.COHORT_LIST
11211121
);
11221122

1123-
const cohortIds = filledValues.mappedResponse.map(item => item.itemId);
1123+
// Check if mappedResponse is empty despite having totalCount > 0
1124+
if (filledValues?.mappedResponse?.length === 0 && filledValues?.totalCount > 0) {
1125+
LoggerUtil.error(
1126+
`MAPPING ISSUE: Database found ${filledValues.totalCount} records but mappedResponse is empty`,
1127+
`Check fieldsService.mappedResponse() method for filtering logic`,
1128+
APIID.COHORT_LIST
1129+
);
1130+
}
1131+
1132+
const cohortIds = filledValues.mappedResponse.map(item => item.itemId).filter(id => id && id !== "");
1133+
1134+
LoggerUtil.log(
1135+
`Extracted ${cohortIds.length} valid cohort IDs from ${filledValues?.mappedResponse?.length} mapped records`,
1136+
APIID.COHORT_LIST
1137+
);
11241138

11251139
if (cohortIds.length === 0) {
11261140
LoggerUtil.error(

src/fields/fields.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,11 @@ export class FieldsService {
10831083
}
10841084

10851085
public async mappedResponse(result: any) {
1086+
LoggerUtil.log(
1087+
`mappedResponse called with ${result?.length} raw records`,
1088+
"api.fieldvalues.mapping"
1089+
);
1090+
10861091
const fieldValueResponse = result.map((item: any) => {
10871092
const fieldValueMapping = {
10881093
value: item?.value ? `${item.value}` : "",
@@ -1098,6 +1103,11 @@ export class FieldsService {
10981103
return new FieldValuesDto(fieldValueMapping);
10991104
});
11001105

1106+
LoggerUtil.log(
1107+
`mappedResponse returning ${fieldValueResponse?.length} mapped records`,
1108+
"api.fieldvalues.mapping"
1109+
);
1110+
11011111
return fieldValueResponse;
11021112
}
11031113

0 commit comments

Comments
 (0)