Skip to content

added session update api and on_update callback#16

Open
nevil-mathew wants to merge 5 commits into
developfrom
session-update
Open

added session update api and on_update callback#16
nevil-mathew wants to merge 5 commits into
developfrom
session-update

Conversation

@nevil-mathew
Copy link
Copy Markdown
Collaborator

No description provided.

@joffinjoy joffinjoy changed the base branch from main to develop February 16, 2023 03:45
Comment thread src/controllers/index.js
}
}

exports.sessionUpdate = async (req, res) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to a session route and a session controller with the controller name being something like "update". So /session/update calling sessionController.update which in-turn calls sessionService.update.

Comment thread src/controllers/index.js
exports.sessionUpdate = async (req, res) => {
try {
console.debug(JSON.stringify(req.body, null, '\t'))
res.status(200).send(responses.success_ack)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This idea of the controller immediately responding with a success acknowledgement doesn't apply to non-dsep or internal calls. Since this is an internal call from mentoring service to bpp, we are no longer dealing with DSEP protocol here. Hence no need to give early response. Here use the regular response flow where success or failure responses are given based on the execution of controller or service logic.

Comment thread src/services/session.js
exports.session = async (requestBody) => {
try {
const sessionId = requestBody.sessionId
const sessionAttendance = await sessionAttendanceQueries.findBySessionId(sessionId)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sessionAttendances" would be more apt here since you are fetching multiple sessionAttendances with common sessionId.

Comment thread src/services/session.js
if (!sessionAttendance) {
return console.log('SessionAttendance Not Found')
}
const userIds = sessionAttendance.map((sessionAttendee) => sessionAttendee.userId)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sessionAttendee" can be a bit confusing here since we already have a sessionAttendeeId in the model. And sessionAttendee is a mentoring service side concept. Just "attendance" would be better than "sessionAttendee" since that doesn't change the idea of what that object represent (which is an attendance, and not attendee).

Comment thread src/services/session.js
sessionAttendanceInfo,
}
})
usersWithBapAndAttendance.map(async (user) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you are switching back to regular responses, a question arises about when to give back a success response to mentoring. Do we do that when all the requests being generated was successful or can we give a success response as soon as we trigger these requests (but without considering if any of them were in-fact successful). Please bring this up as a discussion point with the team.

From my perspective, we shouldn't be checking each and every request to be successful (Feels fragile). If team agrees, you can use promise.race to split the execution and give back the control to controller while requests are still being generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants