Skip to content

Commit

Permalink
Memoize the block_sync_enabled? call for FacilitiesController
Browse files Browse the repository at this point in the history
  • Loading branch information
kitallis committed Dec 17, 2020
1 parent 7cf2e40 commit 0b18ad0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/api/v3/facilities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ def records_to_sync

private

# Memoize this call here so that we don't end up making thousands of calls to check user for each facility
def block_level_sync?
@is_block_level_sync_enabled = current_user&.block_level_sync? if @is_block_level_sync_enabled.nil?
@is_block_level_sync_enabled
end

def sync_region_id(facility)
if current_user&.block_level_sync?
if block_level_sync?
facility.block_region_id
else
facility.facility_group_id
Expand Down

0 comments on commit 0b18ad0

Please sign in to comment.