-
Notifications
You must be signed in to change notification settings - Fork 29
Added changes for new AcademicYear #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sdbv_rbac_changes
Are you sure you want to change the base?
Changes from all commits
befb5c1
075fa8b
0538256
22da91b
fe773d4
ecef51e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -494,7 +494,7 @@ ON CM."userId" = U."userId" ${whereCase}`; | |||||||||||||||||||||||||||||
| res: Response, | ||||||||||||||||||||||||||||||
| tenantId: string, | ||||||||||||||||||||||||||||||
| deviceId: string, | ||||||||||||||||||||||||||||||
| academicyearId: string | ||||||||||||||||||||||||||||||
| academicYearId: string | ||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||
| const apiId = APIID.COHORT_MEMBER_CREATE; | ||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
|
|
@@ -514,7 +514,7 @@ ON CM."userId" = U."userId" ${whereCase}`; | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| // check year is live or not | ||||||||||||||||||||||||||||||
| const academicYear = await this.academicyearService.getActiveAcademicYear( | ||||||||||||||||||||||||||||||
| academicyearId, | ||||||||||||||||||||||||||||||
| academicYearId, | ||||||||||||||||||||||||||||||
| tenantId | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -529,7 +529,7 @@ ON CM."userId" = U."userId" ${whereCase}`; | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| //check this cohort exist this year or not | ||||||||||||||||||||||||||||||
| const isExistAcademicYear = await this.findCohortAcademicYearId( | ||||||||||||||||||||||||||||||
| academicyearId, | ||||||||||||||||||||||||||||||
| academicYearId, | ||||||||||||||||||||||||||||||
| cohortMembers | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| if (!isExistAcademicYear) { | ||||||||||||||||||||||||||||||
|
|
@@ -541,13 +541,13 @@ ON CM."userId" = U."userId" ${whereCase}`; | |||||||||||||||||||||||||||||
| HttpStatus.NOT_FOUND | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const cohortacAdemicyearId = isExistAcademicYear.cohortAcademicYearId; | ||||||||||||||||||||||||||||||
| const cohortAcademicYearId = isExistAcademicYear.cohortAcademicYearId; | ||||||||||||||||||||||||||||||
| //check user is already exist in this cohort for this year or not | ||||||||||||||||||||||||||||||
| const existrole = await this.cohortMembersRepository.find({ | ||||||||||||||||||||||||||||||
| where: { | ||||||||||||||||||||||||||||||
| userId: cohortMembers.userId, | ||||||||||||||||||||||||||||||
| cohortId: cohortMembers.cohortId, | ||||||||||||||||||||||||||||||
| cohortAcademicYearId: cohortacAdemicyearId, | ||||||||||||||||||||||||||||||
| cohortAcademicYearId: cohortAcademicYearId, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| if (existrole.length > 0) { | ||||||||||||||||||||||||||||||
|
|
@@ -562,19 +562,35 @@ ON CM."userId" = U."userId" ${whereCase}`; | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| cohortMembers.createdBy = loginUser; | ||||||||||||||||||||||||||||||
| cohortMembers.updatedBy = loginUser; | ||||||||||||||||||||||||||||||
| cohortMembers.cohortAcademicYearId = cohortacAdemicyearId; | ||||||||||||||||||||||||||||||
| cohortMembers.cohortAcademicYearId = cohortAcademicYearId; | ||||||||||||||||||||||||||||||
| // Create a new CohortMembers entity and populate it with cohortMembers data | ||||||||||||||||||||||||||||||
| const savedCohortMember = await this.cohortMembersRepository.save( | ||||||||||||||||||||||||||||||
| cohortMembers | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return APIResponse.success( | ||||||||||||||||||||||||||||||
| res, | ||||||||||||||||||||||||||||||
| apiId, | ||||||||||||||||||||||||||||||
| savedCohortMember, | ||||||||||||||||||||||||||||||
| HttpStatus.OK, | ||||||||||||||||||||||||||||||
| API_RESPONSES.COHORTMEMBER_CREATED_SUCCESSFULLY | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| if (savedCohortMember) { | ||||||||||||||||||||||||||||||
| const apiResponse = APIResponse.success( | ||||||||||||||||||||||||||||||
| res, | ||||||||||||||||||||||||||||||
| apiId, | ||||||||||||||||||||||||||||||
| savedCohortMember, | ||||||||||||||||||||||||||||||
| HttpStatus.OK, | ||||||||||||||||||||||||||||||
| API_RESPONSES.COHORTMEMBER_CREATED_SUCCESSFULLY | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const enrichedData = { | ||||||||||||||||||||||||||||||
| ...savedCohortMember, | ||||||||||||||||||||||||||||||
| academicYearId, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| this.kafkaService.publishCohortMemberEvent('created', enrichedData, enrichedData.cohortMembershipId).catch(error => { | ||||||||||||||||||||||||||||||
| LoggerUtil.error( | ||||||||||||||||||||||||||||||
| `Failed to publish cohort member created event to Kafka`, | ||||||||||||||||||||||||||||||
| `Error: ${error.message}`, | ||||||||||||||||||||||||||||||
| enrichedData.cohortAcademicYearId | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
|
Comment on lines
+585
to
+591
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent Kafka event publishing. In
Suggested change
|
||||||||||||||||||||||||||||||
| return apiResponse; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||
| LoggerUtil.error( | ||||||||||||||||||||||||||||||
| `${API_RESPONSES.SERVER_ERROR}`, | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
LoggerUtil.errorcall in the catch block is inconsistent with the rest of the file. Usually,apiIdis passed as the third argument (context) to allow for better log tracing and filtering. UsingenrichedData.cohortAcademicYearIdas the context here deviates from that pattern.