Commit f5a4e96a5efffd28addc98453234866e990202b9
Committed by
Antonio Terceiro
1 parent
956cd5b1
Exists in
master
and in
23 other branches
ActionItem1218: adding folder name on cache
Cache from homepage was not being expired after changing portal folder
Showing
3 changed files
with
6 additions
and
2 deletions
Show diff stats
app/controllers/public/home_controller.rb
| @@ -4,7 +4,7 @@ class HomeController < PublicController | @@ -4,7 +4,7 @@ class HomeController < PublicController | ||
| 4 | @has_news = false | 4 | @has_news = false |
| 5 | if environment.enabled?('use_portal_community') && environment.portal_community | 5 | if environment.enabled?('use_portal_community') && environment.portal_community |
| 6 | @has_news = true | 6 | @has_news = true |
| 7 | - @news_cache_key = "home_page_news_#{environment.id.to_s}" | 7 | + @news_cache_key = environment.portal_news_cache_key |
| 8 | if !read_fragment(@news_cache_key) | 8 | if !read_fragment(@news_cache_key) |
| 9 | portal_community = environment.portal_community | 9 | portal_community = environment.portal_community |
| 10 | @portal_news = portal_community.news(5) | 10 | @portal_news = portal_community.news(5) |
app/models/environment.rb
| @@ -658,6 +658,10 @@ class Environment < ActiveRecord::Base | @@ -658,6 +658,10 @@ class Environment < ActiveRecord::Base | ||
| 658 | self.settings['tip_message_enterprise_activation_question'] = value | 658 | self.settings['tip_message_enterprise_activation_question'] = value |
| 659 | end | 659 | end |
| 660 | 660 | ||
| 661 | + def portal_news_cache_key | ||
| 662 | + "home-page-news-#{id}_#{portal_community.name}" | ||
| 663 | + end | ||
| 664 | + | ||
| 661 | after_create :create_templates | 665 | after_create :create_templates |
| 662 | 666 | ||
| 663 | def create_templates | 667 | def create_templates |
app/sweepers/article_sweeper.rb
| @@ -22,7 +22,7 @@ protected | @@ -22,7 +22,7 @@ protected | ||
| 22 | blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} | 22 | blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} |
| 23 | env = article.profile.environment | 23 | env = article.profile.environment |
| 24 | if env.portal_community == article.profile | 24 | if env.portal_community == article.profile |
| 25 | - expire_fragment("home_page_news_#{env.id}") | 25 | + expire_fragment(env.portal_news_cache_key) |
| 26 | end | 26 | end |
| 27 | end | 27 | end |
| 28 | 28 |