Class: Renalware::HD::ArchiveYesterdaysSlotsJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Renalware::HD::ArchiveYesterdaysSlotsJob
- Defined in:
- app/models/renalware/hd/archive_yesterdays_slots_job.rb
Instance Attribute Summary collapse
-
#up_until ⇒ Object
readonly
Returns the value of attribute up_until.
Instance Method Summary collapse
-
#perform(up_until: nil) ⇒ Object
:reek:UtilityFunction.
Instance Attribute Details
#up_until ⇒ Object (readonly)
Returns the value of attribute up_until.
32 33 34 |
# File 'app/models/renalware/hd/archive_yesterdays_slots_job.rb', line 32 def up_until @up_until end |
Instance Method Details
#perform(up_until: nil) ⇒ Object
:reek:UtilityFunction
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/renalware/hd/archive_yesterdays_slots_job.rb', line 35 def perform(up_until: nil) @up_until = up_until&.to_date @up_until ||= (Time.zone.today - 1.day) diary = Diary.find_by(year: @up_until.year, week_number: @up_until.cweek) return unless diary diary .slots .unarchived .where(day_of_week: @up_until.cwday) .update_all(archived: true, archived_at: Time.zone.now) # DiarySlot # .unarchived # .joins(:diary) # .where(hd_diaries: { year: up_until.year, week_number: up_until.cweek) # .update_all(archived: true, archived_at: Time.zone.now) end |