Commit 5e1975c666d75074c959824214b3ad6a17fe46f4
1 parent
84d46551
Exists in
master
and in
28 other branches
Added locale on caches
- Environment homepage cache (ActionItem2336)
Showing
3 changed files
with
6 additions
and
4 deletions
Show diff stats
app/controllers/public/home_controller.rb
... | ... | @@ -4,7 +4,7 @@ class HomeController < PublicController |
4 | 4 | @has_news = false |
5 | 5 | if environment.enabled?('use_portal_community') && environment.portal_community |
6 | 6 | @has_news = true |
7 | - @news_cache_key = environment.portal_news_cache_key | |
7 | + @news_cache_key = environment.portal_news_cache_key(FastGettext.locale) | |
8 | 8 | if !read_fragment(@news_cache_key) |
9 | 9 | portal_community = environment.portal_community |
10 | 10 | @highlighted_news = portal_community.news(2, true) | ... | ... |
app/models/environment.rb
... | ... | @@ -696,8 +696,8 @@ class Environment < ActiveRecord::Base |
696 | 696 | settings[:portal_folders] = folders ? folders.map(&:id) : nil |
697 | 697 | end |
698 | 698 | |
699 | - def portal_news_cache_key | |
700 | - "home-page-news/#{cache_key}" | |
699 | + def portal_news_cache_key(language='en') | |
700 | + "home-page-news/#{cache_key}-#{language}" | |
701 | 701 | end |
702 | 702 | |
703 | 703 | def notification_emails | ... | ... |
app/sweepers/article_sweeper.rb
... | ... | @@ -20,7 +20,9 @@ protected |
20 | 20 | BlockSweeper.expire_blocks(blocks) |
21 | 21 | env = article.profile.environment |
22 | 22 | if env && (env.portal_community == article.profile) |
23 | - expire_fragment(env.portal_news_cache_key) | |
23 | + Noosfero.locales.keys.each do |locale| | |
24 | + expire_fragment(env.portal_news_cache_key(locale)) | |
25 | + end | |
24 | 26 | end |
25 | 27 | end |
26 | 28 | ... | ... |