Skip to content

Instantly share code, notes, and snippets.

@maxehmookau
Last active July 11, 2017 15:22
Show Gist options
  • Save maxehmookau/138435d60014e57f7d26458820963dd2 to your computer and use it in GitHub Desktop.
Save maxehmookau/138435d60014e57f7d26458820963dd2 to your computer and use it in GitHub Desktop.
Preloading patient details
web_1 | I, [2017-07-11T14:01:06.771698 #11] INFO -- : Enqueued PreloadPatientRecordsJob (Job ID: ba184519-ccdb-4486-8c58-2cbe53b5abec) to Sidekiq(default) with arguments: #<GlobalID:0x007efe11a29890 @uri=#<URI::GID gid://myhealthcare/User/1>>
sidekiq_1 | 2017-07-11T14:01:08.087Z 1 TID-gs5hwxk04 PreloadPatientRecordsJob JID-d4d16a61150c753aed7c75be INFO: start
sidekiq_1 | D, [2017-07-11T14:01:10.062434 #1] DEBUG -- : Setting cache key: details.
sidekiq_1 | D, [2017-07-11T14:01:10.082970 #1] DEBUG -- : Setting cache key: observations.
sidekiq_1 | D, [2017-07-11T14:01:10.149937 #1] DEBUG -- : Setting cache key: conditions.
sidekiq_1 | D, [2017-07-11T14:01:10.172276 #1] DEBUG -- : Setting cache key: allergies.
sidekiq_1 | D, [2017-07-11T14:01:10.194290 #1] DEBUG -- : Setting cache key: immunizations.
sidekiq_1 | D, [2017-07-11T14:01:10.214040 #1] DEBUG -- : Setting cache key: all_medications.
sidekiq_1 | D, [2017-07-11T14:01:10.252209 #1] DEBUG -- : Setting cache key: registration_status.
sidekiq_1 | I, [2017-07-11T14:01:10.255647 #1] INFO -- : Performed PreloadPatientRecordsJob from Sidekiq(default) in 2117.8ms
sidekiq_1 | 2017-07-11T14:01:10.256Z 1 TID-gs5hwxk04 PreloadPatientRecordsJob JID-d4d16a61150c753aed7c75be INFO: done: 2.17 sec
class User < ApplicationRecord
devise ....
after_update :preload_records, if: -> { last_sign_in_at_changed? }
private
def preload_records
PatientPreloadWorker.perform_later(self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment