Class: Caddie::CrestPriceHistoryLastDayTimestamp
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Caddie::CrestPriceHistoryLastDayTimestamp
- Defined in:
- app/models/caddie/crest_price_history_last_day_timestamp.rb
Class Method Summary collapse
- .create_or_update_last_day_timestamp(last_update_record, max_date_info, region_id, eve_item_id) ⇒ Object
- .find_or_create_last_day_timestamp(region_id, eve_item_id) ⇒ Object
Class Method Details
.create_or_update_last_day_timestamp(last_update_record, max_date_info, region_id, eve_item_id) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/models/caddie/crest_price_history_last_day_timestamp.rb', line 21 def self.( last_update_record, max_date_info, region_id, eve_item_id ) if last_update_record last_update_record.update!( day_timestamp: max_date_info ) else last_update_record = CrestPriceHistoryLastDayTimestamp.create!( region_id: region_id, eve_item_id: eve_item_id, day_timestamp: max_date_info ) end last_update_record end |
.find_or_create_last_day_timestamp(region_id, eve_item_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/caddie/crest_price_history_last_day_timestamp.rb', line 6 def self.( region_id, eve_item_id ) last_update_record = CrestPriceHistoryLastDayTimestamp.find_by_region_id_and_eve_item_id( region_id, eve_item_id ) if last_update_record last_update_date = last_update_record. else last_update_date = CrestPriceHistory.where( region_id: region_id, eve_item_id: eve_item_id ).maximum( :history_date ) end last_update_date = Time.new( 0 ) unless last_update_date [ last_update_date, last_update_record ] end |