20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/models/bookmark_stat.rb', line 20
def calculate_count!
self.started_at = Time.zone.now
Manifestation.find_each do |manifestation|
daily_count = Bookmark.manifestations_count(start_date, end_date, manifestation)
if daily_count > 0
self.manifestations << manifestation
sql = ['UPDATE bookmark_stat_has_manifestations SET bookmarks_count = ? WHERE bookmark_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
transition_to!(:completed)
end
|