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

Remove N+1 on register attendance page #2770

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Remove N+1 on register attendance page #2770

merged 1 commit into from
Dec 17, 2024

Conversation

tvararu
Copy link
Member

@tvararu tvararu commented Dec 17, 2024

The .select was causing a query for session_attendances based on today's @session_date.

Instead, we can more directly use two where clauses:

  • Either for patient sessions with no attendances
  • Or for patient sessions with attendances but not on today's date

The patient sessions need to be stored in an intermediate ps variable to maintain the joins from includes when using .or.

The `.select` was causing a query for `session_attendances` based on
today's `@session_date`.

Instead, we can more directly use two `where` clauses:

- Either for patient sessions with no attendances
- Or for patient sessions with attendances but not on today's date

The patient sessions need to be stored in an intermediate `ps` variable
to maintain the joins from `includes` when using `.or`.
@tvararu tvararu merged commit 00ff915 into main Dec 17, 2024
13 checks passed
@tvararu tvararu deleted the perf2 branch December 17, 2024 09:57
@tvararu tvararu added this to the v1.1.1 milestone Dec 17, 2024
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.

2 participants