diff --git a/app/models/profile.rb b/app/models/profile.rb index badad8a..05aeb6f 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -638,4 +638,9 @@ class Profile < ActiveRecord::Base ProfileSweeper.new().after_update(profile) end + # FIXME: horrible workaround to circular dependancy in environment.rb + after_create do |profile| + ProfileSweeper.new().after_create(profile) + end + end diff --git a/app/sweepers/profile_sweeper.rb b/app/sweepers/profile_sweeper.rb index 1e4ddbb..d7b7f33 100644 --- a/app/sweepers/profile_sweeper.rb +++ b/app/sweepers/profile_sweeper.rb @@ -7,6 +7,10 @@ class ProfileSweeper # < ActiveRecord::Observer expire_caches(profile) end + def after_create(profile) + expire_statistics_block_cache(profile) + end + protected def expire_caches(profile) @@ -19,4 +23,9 @@ protected expire_timeout_fragment(block.cache_keys) end end + + def expire_statistics_block_cache(profile) + blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } + blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} + end end -- libgit2 0.21.2