Skip to content
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

Fixing Alerts flow #836

Merged
merged 20 commits into from Feb 24, 2022
Merged

Fixing Alerts flow #836

merged 20 commits into from Feb 24, 2022

Conversation

VKong6019
Copy link
Contributor

@VKong6019 VKong6019 commented Feb 13, 2022

Description

Fixing the alerts/rephrase question flow that never got merged in before. Should allow TAs/Profs to ask students to rephrase their question multiple times. Note: the rephrase tooltip is not displayed for grouped questions cause they're grouped xd.

alerts

Closes #803
Closes #661

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe how you tested this PR (both manually and with tests)
Provide instructions so we can reproduce.

  • With the power of manual testing

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code where needed
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

NEUDitao and others added 9 commits February 1, 2022 02:41
- Need 2 alert GET calls for some reason in order to fetch back the new
  alerts list
- Pass correct AlertModel type to service
- Fetch 'stafflist` relation on queue so that `checkIsOpen` works
@vercel
Copy link

vercel bot commented Feb 13, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sandboxneu/office-hours/FhGThhkgzpqiBsJmAbzCsKACMq2z
✅ Preview: https://office-hours-git-vk-fix-fix-alerts-sandboxneu.vercel.app

Copy link
Collaborator

@IrisLiu-00 IrisLiu-00 left a comment

Choose a reason for hiding this comment

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

Thanks for getting this 🙏 🙏
I manual tested it some, looks good as far as i can tell!

packages/app/components/Nav/AlertsContainer.tsx Outdated Show resolved Hide resolved
packages/app/components/Queue/TA/TAQueueDetailButtons.tsx Outdated Show resolved Hide resolved
packages/server/src/alerts/alerts.entity.ts Outdated Show resolved Hide resolved
packages/server/src/alerts/alerts.service.spec.ts Outdated Show resolved Hide resolved
@@ -136,6 +142,21 @@ export default function TAQueueDetailButtons({
return [true, "Help Student"];
}
})();
const [canRephrase, rephraseTooltip] = ((): [boolean, string] => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

merged the two ternaries into this pair. kinda just followed the same pattern as [canHelp, helpTooltip], but do lmk if there's a better way to organize them

],
exports: [QueueCleanService, QueueSSEService],
imports: [SSEModule],
imports: [SSEModule, AlertsModule],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

im boomer, AlertsModule needs to be added/kept here right? for dependencies and stuff

Copy link
Contributor Author

@VKong6019 VKong6019 Feb 24, 2022

Choose a reason for hiding this comment

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

oh i see the problem

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so? I forget bc it's been a while since I've used worked with these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea i think we do in order to inject the AlertsService I added

@dfarooq610
Copy link
Collaborator

I don't know if we can do much about this, but the alert is resolved when the question modal pops up -- not when the person closes out of the question modal. So it can result in some weird scenarios like this (asking a student to resolve their question again as they are trying to address their previous question).

It doesnt error out though so it shouldnt be too bad
Screen Recording 2022-02-24 at 9 47 00 AM (1)

@IrisLiu-00
Copy link
Collaborator

I don't know if we can do much about this, but the alert is resolved when the question modal pops up -- not when the person closes out of the question modal. So it can result in some weird scenarios like this (asking a student to resolve their question again as they are trying to address their previous question).

Hmm I think we can maybe consider that as just people using the app incorrectly - it doesn't seem all that likely that a TA will be impatient enough to ask a student to requestion while the student is still editing

Unless Vera is really gung ho to do some refactoring of our alerts architecture lol

Copy link
Collaborator

@IrisLiu-00 IrisLiu-00 left a comment

Choose a reason for hiding this comment

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

Great stuff!

Copy link
Collaborator

@dfarooq610 dfarooq610 left a comment

Choose a reason for hiding this comment

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

Overall, everything seems to work nicely!

Some really minor nits, but otherwise it's good! Thanks for picking up this ticket!

user,
resolved: null,
},
});
return { alerts: await this.alertsService.removeStaleAlerts(alerts) };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not related to your PR exactly: but do we clean up alerts at night? I wonder what happens when when I ask a student to rephrase their question today, they never address it, and they open up the app tomorrow?

Maybe nothing because the questions are cleaned from the queue (and hence there will be no alerts in the ListQuestionsResponse). Do we want to mark alerts as Stale when closing these questions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think it should be fine because theoretically this removeStaleAlerts gets called whenever alerts are fetched. So when the student checks in the next time in the course, i think the old alerts should be culled

    const alerts = await AlertModel.find({
      where: {
        courseId,
        user,
        resolved: null,
      },
    });

return await AlertModel.createQueryBuilder('alert')
.where('alert.resolved IS NULL')
.andWhere('alert.alertType = :alertType', { alertType })
.andWhere("(alert.payload ->> 'queueId')::INTEGER = :queueId ", {
Copy link
Collaborator

Choose a reason for hiding this comment

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

~fancy~

packages/server/src/alerts/alerts.service.ts Outdated Show resolved Hide resolved
const queue = await QueueModel.findOne(payload.queueId);
if (question.closedAt || !(await queue.checkIsOpen())) {
console.log(`Rephrase Question alert with id ${alert.id} expired`);
const queue = await QueueModel.findOne(payload.queueId, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: Why do we need to load the stafflist here? Is it to check if the queue is open?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc: @IrisLiu-00
iirc, i think it had smth to do with fetching correctly. related to this pr:#834

],
exports: [QueueCleanService, QueueSSEService],
imports: [SSEModule],
imports: [SSEModule, AlertsModule],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so? I forget bc it's been a while since I've used worked with these

@VKong6019
Copy link
Contributor Author

I don't know if we can do much about this, but the alert is resolved when the question modal pops up -- not when the person closes out of the question modal. So it can result in some weird scenarios like this (asking a student to resolve their question again as they are trying to address their previous question).

Hmm I think we can maybe consider that as just people using the app incorrectly - it doesn't seem all that likely that a TA will be impatient enough to ask a student to requestion while the student is still editing

Unless Vera is really gung ho to do some refactoring of our alerts architecture lol

i have smol amount of faith the TA doesn't spam the button

Copy link
Collaborator

@dfarooq610 dfarooq610 left a comment

Choose a reason for hiding this comment

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

🥳

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.

E2E test the re-question feature! Fix rephrase question bug
4 participants