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

(B) QTY-14939 Fix hammering attendance API #491

Merged
merged 13 commits into from
Mar 14, 2025

Conversation

markng
Copy link
Contributor

@markng markng commented Mar 7, 2025

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

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]>
@markng markng requested a review from a team as a code owner March 7, 2025 18:18
@markng markng marked this pull request as draft March 7, 2025 18:34
Copy link

@Copilot Copilot AI left a 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

Copy link
Contributor

@tylerCaineRhodes tylerCaineRhodes left a comment

Choose a reason for hiding this comment

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

Approved with comments.

markng and others added 3 commits March 13, 2025 14:48
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]>
@markng markng marked this pull request as ready for review March 14, 2025 18:05
@markng markng merged commit 55ea7f2 into main Mar 14, 2025
3 checks passed
@markng markng deleted the QTY-14939-enable-lockout-from-env branch March 14, 2025 18:05
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