Sha256: 6e77fce1705d6de82d7697eaa795389f9818b61883884efcbf674695886e6350
Contents?: true
Size: 499 Bytes
Versions: 12
Compression:
Stored size: 499 Bytes
Contents
desc "Update counter caches" task :update_counter_caches => :environment do # Update the Venue#events_count total = Calagator::Venue.count Calagator::Venue.all.each do |venue| cached = venue.events_count actual = venue.events.count if actual != cached puts "Updating Venue ##{venue.id} from #{cached} cached to #{actual} actual -- #{venue.title}" Calagator::Venue.connection.update("UPDATE venues SET events_count = #{actual} WHERE id = #{venue.id}") end end end
Version data entries
12 entries across 12 versions & 2 rubygems