18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/models/manifestation_checkout_stat.rb', line 18
def calculate_count
self.started_at = Time.zone.now
Manifestation.find_each do |manifestation|
daily_count = Checkout.manifestations_count(self.start_date, self.end_date, manifestation)
if daily_count > 0
self.manifestations << manifestation
sql = ['UPDATE checkout_stat_has_manifestations SET checkouts_count = ? WHERE manifestation_checkout_stat_id = ? AND manifestation_id = ?', daily_count, self.id, manifestation.id]
ActiveRecord::Base.connection.execute(
self.class.send(:sanitize_sql_array, sql)
)
end
end
self.completed_at = Time.zone.now
end
|