Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/adapters/postgres/cohortMembers-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PostgresCohortMembersService {
private readonly notificationRequest: NotificationRequest,
private fieldsService: PostgresFieldsService,
private userService: PostgresUserService
) { }
) {}

//Get cohort member
async getCohortMembers(
Expand Down Expand Up @@ -128,7 +128,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${e.message}`,
apiId
)
);
const errorMessage = e.message || API_RESPONSES.INTERNAL_SERVER_ERROR;
return APIResponse.error(
res,
Expand Down Expand Up @@ -384,7 +384,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${e.message}`,
apiId
)
);
const errorMessage = e.message || API_RESPONSES.INTERNAL_SERVER_ERROR;
return APIResponse.error(
res,
Expand Down Expand Up @@ -450,8 +450,10 @@ export class PostgresCohortMembersService {
if (fieldShowHide === "false") {
results.userDetails.push(data);
} else {
const fieldValues =
await this.fieldsService.getCustomFieldDetails(data.userId, 'Users');
const fieldValues = await this.fieldsService.getCustomFieldDetails(
data.userId,
"Users"
);
//get data by cohort membership Id
let fieldValuesForCohort =
await this.fieldsService.getFieldsAndFieldsValues(
Expand Down Expand Up @@ -567,7 +569,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${e.message}`,
apiId
)
);
const errorMessage = e.message || API_RESPONSES.INTERNAL_SERVER_ERROR;
return APIResponse.error(
res,
Expand Down Expand Up @@ -623,7 +625,7 @@ export class PostgresCohortMembersService {
}

let query = `SELECT U."userId", U."enrollmentId", U."username", "firstName", "middleName", "lastName", R."name" AS role, U."mobile",U."deviceId",
CM."status", CM."statusReason",CM."cohortMembershipId",CM."status",CM."createdAt", CM."updatedAt",U."createdBy",U."updatedBy", COUNT(*) OVER() AS total_count FROM public."CohortMembers" CM
CM."status", CM."statusReason",CM."cohortMembershipId",CM."params",CM."status",CM."createdAt", CM."updatedAt",U."createdBy",U."updatedBy", COUNT(*) OVER() AS total_count FROM public."CohortMembers" CM
INNER JOIN public."Users" U
ON CM."userId" = U."userId"
INNER JOIN public."UserRolesMapping" UR
Expand Down Expand Up @@ -700,9 +702,11 @@ export class PostgresCohortMembersService {
}
}

let cohortMembershipToUpdate = await this.cohortMembersRepository.findOne({
where: { cohortMembershipId: cohortMembershipId },
});
let cohortMembershipToUpdate = await this.cohortMembersRepository.findOne(
{
where: { cohortMembershipId: cohortMembershipId },
}
);

if (!cohortMembershipToUpdate) {
return APIResponse.error(
Expand Down Expand Up @@ -766,7 +770,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${error.message}`,
apiId
)
);

return APIResponse.error(
response,
Expand All @@ -776,8 +780,6 @@ export class PostgresCohortMembersService {
HttpStatus.INTERNAL_SERVER_ERROR
);
}


}

public async deleteCohortMemberById(
Expand Down Expand Up @@ -820,7 +822,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${e.message}`,
apiId
)
);
const errorMessage = e.message || API_RESPONSES.SERVER_ERROR;
return APIResponse.error(
res,
Expand Down Expand Up @@ -954,7 +956,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${error.message}`,
apiId
)
);
errors.push(
API_RESPONSES.ERROR_UPDATE_COHORTMEMBER(
userId,
Expand All @@ -967,10 +969,7 @@ export class PostgresCohortMembersService {
}

// Handling of Addition of User in Cohort
if (
cohortMembersDto?.cohortId &&
cohortMembersDto?.cohortId.length > 0
) {
if (cohortMembersDto?.cohortId && cohortMembersDto?.cohortId.length > 0) {
for (const cohortId of cohortMembersDto.cohortId) {
const cohortMembers = {
...cohortMembersBase,
Expand Down Expand Up @@ -1038,7 +1037,7 @@ export class PostgresCohortMembersService {
`${API_RESPONSES.SERVER_ERROR}`,
`Error: ${error.message}`,
apiId
)
);
errors.push(
API_RESPONSES.ERROR_SAVING_COHORTMEMBER(
userId,
Expand Down
Loading