Skip to content

Make sure polling results are only sent to instructors#76

Merged
shubhbapna merged 2 commits intoutmgdsc:dev/gdsc-open-source-2022from
embeddedt:fix-network-traffic
Jan 6, 2023
Merged

Make sure polling results are only sent to instructors#76
shubhbapna merged 2 commits intoutmgdsc:dev/gdsc-open-source-2022from
embeddedt:fix-network-traffic

Conversation

@embeddedt
Copy link

As discovered while testing the fix for #50, add socket.io rooms for each user type, and ensure that result messages are only sent to the instructor room.

The user type is fetched once on socket connection and then cached, which means this approach should not add additional load to each vote.

});
io.use(async (socket, next) => {
const userType = await getUser(socket.data.utorid);
socket.data["userType"] = userType.data.userType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not do this in the first place?

Suggested change
socket.data["userType"] = userType.data.userType;
socket.data.userType = userType.data.userType;

Copy link
Author

Choose a reason for hiding this comment

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

I was preserving the code style from line 50, where the assignment seems to use the [""] notation.

@embeddedt embeddedt marked this pull request as draft October 25, 2022 11:30
Copy link
Collaborator

@shubhbapna shubhbapna left a comment

Choose a reason for hiding this comment

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

@embeddedt I would like to include this PR even when we need #82 because we just want to show the results when the prof presses the button. Could you:

  1. Change the target branch to the open source branch
  2. Create types/user.types.ts and store a UserType enum instead of using literal strings

@embeddedt embeddedt changed the base branch from main to dev/gdsc-open-source-2022 December 23, 2022 18:08
@embeddedt embeddedt requested review from shubhbapna and removed request for hiimchrislim December 23, 2022 19:40
@embeddedt embeddedt marked this pull request as ready for review December 23, 2022 19:40
Copy link
Collaborator

@shubhbapna shubhbapna left a comment

Choose a reason for hiding this comment

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

LGTM

@shubhbapna shubhbapna merged commit 7d1a8ef into utmgdsc:dev/gdsc-open-source-2022 Jan 6, 2023
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.

3 participants