-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve Sync To User performance (batch 1) #1896
Changes from 2 commits
7cf2e40
0b18ad0
2f3af87
4a4e9a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,13 @@ class Facility < ApplicationRecord | |
foreign_key: "assigned_facility_id" | ||
|
||
pg_search_scope :search_by_name, against: {name: "A", slug: "B"}, using: {tsearch: {prefix: true, any_word: true}} | ||
scope :with_block_region_id, -> { | ||
return all unless Flipper.enabled?(:regions_prep) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the feature flag check should go up into the sync code that is building up the query...having it done in the scope itself is hard to understand. It isn't clear why |
||
|
||
joins("INNER JOIN regions facility_regions ON facility_regions.source_id = facilities.id") | ||
.joins("INNER JOIN regions block_region ON block_region.path @> facility_regions.path AND block_region.region_type = 'block'") | ||
.select("block_region.id AS block_region_id, facilities.*") | ||
} | ||
|
||
enum facility_size: { | ||
community: "community", | ||
|
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.
Can you change this to match the more idiomatic way of doing this type of nil-safe memoization?
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.
Ah, wasn't aware of this, this seems a lot better, thanks!