Commit 9ef7a07492b1ae51a906ca3341e1056e710629bc
Committed by
Antonio Terceiro
1 parent
c54ef437
Exists in
master
and in
29 other branches
ActionItem1197: expiring statistics block cache
When a new profile is created, statistics block should be updated
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -638,4 +638,9 @@ class Profile < ActiveRecord::Base |
638 | 638 | ProfileSweeper.new().after_update(profile) |
639 | 639 | end |
640 | 640 | |
641 | + # FIXME: horrible workaround to circular dependancy in environment.rb | |
642 | + after_create do |profile| | |
643 | + ProfileSweeper.new().after_create(profile) | |
644 | + end | |
645 | + | |
641 | 646 | end | ... | ... |
app/sweepers/profile_sweeper.rb
... | ... | @@ -7,6 +7,10 @@ class ProfileSweeper # < ActiveRecord::Observer |
7 | 7 | expire_caches(profile) |
8 | 8 | end |
9 | 9 | |
10 | + def after_create(profile) | |
11 | + expire_statistics_block_cache(profile) | |
12 | + end | |
13 | + | |
10 | 14 | protected |
11 | 15 | |
12 | 16 | def expire_caches(profile) |
... | ... | @@ -19,4 +23,9 @@ protected |
19 | 23 | expire_timeout_fragment(block.cache_keys) |
20 | 24 | end |
21 | 25 | end |
26 | + | |
27 | + def expire_statistics_block_cache(profile) | |
28 | + blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } | |
29 | + blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} | |
30 | + end | |
22 | 31 | end | ... | ... |