Skip to content

Commit

Permalink
model -> model_sync_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kitallis committed Dec 18, 2020
1 parent 25b5a20 commit 5f0a890
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v3/blood_sugars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def sync_to_user

private

def model
def model_sync_scope
super.for_v3
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v3/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request_metadata
end

def current_facility_records
model
model_sync_scope
.where(id: current_facility.syncable_patients.pluck(:id))
.updated_on_server_since(current_facility_processed_since, limit)
end
Expand All @@ -24,7 +24,7 @@ def other_facility_records
other_patient_records =
current_sync_region.syncable_patients.pluck(:id) - current_facility.syncable_patients.pluck(:id)

model
model_sync_scope
.where(id: other_patient_records)
.updated_on_server_since(other_facilities_processed_since, other_facilities_limit)
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/concerns/api/v3/sync_to_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Api::V3::SyncToUser

included do
def current_facility_records
model
model_sync_scope
.where(patient: current_facility.syncable_patients.pluck(:id))
.updated_on_server_since(current_facility_processed_since, limit)
end
Expand All @@ -13,14 +13,14 @@ def other_facility_records
other_patient_records =
current_sync_region.syncable_patients.pluck(:id) - current_facility.syncable_patients.pluck(:id)

model
model_sync_scope
.where(patient: other_patient_records)
.updated_on_server_since(other_facilities_processed_since, other_facilities_limit)
end

private

def model
def model_sync_scope
controller_name.classify.constantize.for_sync
end

Expand Down

0 comments on commit 5f0a890

Please sign in to comment.