-
Notifications
You must be signed in to change notification settings - Fork 2
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
(B) QTY-14939 Fix hammering attendance API #491
Conversation
For schools that do not use attendance lockouts, we are currently hitting the attendance API and getting a 404, triggering an exception to sentry and causing attendance API to do way more work than it should. Fix this by checking for an env var ( ATTENDANCE_LOCKOUT_ENABLED ). Co-authored-by: Tyler Rhodes <[email protected]>
Co-authored-by: Tyler Rhodes <[email protected]>
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.
Pull Request Overview
This PR fixes the hammering of the attendance API for environments where attendance lockouts are disabled by checking for the ATTENDANCE_LOCKOUT_DISABLED environment variable.
- Updated test cases to validate behavior when the environment variable is set or not set.
- Refactored the locked_out? method in the attendance service to return false early when the environment variable is present and rearranged helper methods.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
spec/services/attendance_service/commands/check_lockout_spec.rb | Added contexts and updated tests for handling attendance lockout based on the environment variable |
app/services/attendance_service/commands/check_lockout.rb | Modified locked_out? method and reorganized helper methods for clarity |
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.
Approved with comments.
Because of a missing after do to clean up env, we were inconsistently failing. Also, we don't need a user check is we have a pseudonym, so remove that extra call (both complexity and performance). Co-authored-by: Mike Benner <[email protected]>
Co-authored-by: Mike Benner <[email protected]>
Link to Jira ticket
Purpose
For schools that do not use attendance lockouts, we are currently hitting the attendance API and getting a 404, triggering an exception to sentry and causing attendance API to do way more work than it should.
Approach
Fix this by checking for an env var ( ATTENDANCE_LOCKOUT_DISABLED ).
Testing
Manual testing + unit testing