-
Notifications
You must be signed in to change notification settings - Fork 192
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
Don't send Course Completion email twice (course already complete) #7405
Conversation
Should we check other generators and maybe add a similar "previous" status there? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #7405 +/- ##
=========================================
Coverage 50.94% 50.95%
- Complexity 11153 11156 +3
=========================================
Files 613 613
Lines 47067 47073 +6
Branches 404 404
=========================================
+ Hits 23980 23986 +6
Misses 22760 22760
Partials 327 327
Continue to review full report in Codecov by Sentry.
|
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.
Hi @merkushin!
The code looks good to me. I just added 2 small comments about the docs.
I tried to complete the course twice by navigating back, but I couldn't. Maybe I'm doing something in a different way?
Screen.Recording.2023-12-27.at.11.26.05.mov
I recorded it as an admin user, but after that I also tested as a student, and I had the same behavior.
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.
As there is a change in the hook, probably we should add the hook
s label as well
Co-authored-by: Renatho De Carli Rosa <renatho@gmail.com>
@renatho Oh no, you're right. I confused two different emails (one for the teacher and another one for the student), thinking this is the same one when I go back and then forward with the browser navigation 🤦 But the solution I tested on a different website where I have different emails ("physically") for the teacher and for the student. Update: tried with and without Learning Mode, with the Course and Astra themes, in Chrome and in Edge. And I can't reproduce the same behavior as the user described. Worth noticing, they said they can't reliably reproduce it in all browsers and they suppose it might depend on browser settings. |
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.
Worth noticing, they said they can't reliably reproduce it in all browsers and they suppose it might depend on browser settings.
I see! So I'm already approving it, in case you think it's the best approach.
But I'd like to propose another thing to think about and see what you think. In this case, wouldn't be better to completely skip the event earlier? So maybe we could take the opportunity to avoid other issues like this in the future. Maybe we could also log an error? I'd say display an error message to the user but I imagine it would be something more complicated, right?
Anyway, if you think your current approach is better after your exploration, feel free to merge it.
Thanks @renatho!
I spent some time reflecting on it. I think we shouldn't stop firing the event. The hook was added many years ago. Changing the behavior sounds risky. And I can't say securely that's worth doing from the app logic viewpoint: I can imagine useful use-cases.
Here, I think, the important thing is that it is not an error. What I mean is that the end user (a student) shouldn't care about what happens under the hood. The app decides if a message should be sent. As I can get the problem, it happens because of some client-side caching. Usually, to avoid such cases, we redirect a user after every POST-request. The same we do here. (Worth noticing that the user doesn't experience issues with Lesson Completion emails!) To sum up, I think in this PR we improve the logic a bit by checking the previous status, but not harm anyone with unnecessary logs or error messages. |
Resolves #7404
Proposed Changes
sensei_course_status_updated
hook, providing previous status.Testing Instructions
New/Updated Hooks
sensei_course_status_updated
— fourth param added:$previous_status
— status before updating to the new one.Pre-Merge Checklist