diff --git a/app/models/budget/stats.rb b/app/models/budget/stats.rb index 4d62cd6de..04cc6d480 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -192,7 +192,7 @@ class Budget::Stats stats_cache(*stats_methods) - def stats_cache(key, &) - Rails.cache.fetch("budgets_stats/#{budget.id}/#{phases.join}/#{key}/#{version}", &) + def full_cache_key_for(key) + "budgets_stats/#{budget.id}/#{phases.join}/#{key}/#{version}" end end diff --git a/app/models/concerns/statisticable.rb b/app/models/concerns/statisticable.rb index 9d47720ee..8e4ea424c 100644 --- a/app/models/concerns/statisticable.rb +++ b/app/models/concerns/statisticable.rb @@ -224,4 +224,8 @@ module Statisticable I18n.t("stats.age_range", start: start, finish: finish) end end + + def stats_cache(key, &) + Rails.cache.fetch(full_cache_key_for(key), &) + end end diff --git a/app/models/poll/stats.rb b/app/models/poll/stats.rb index c449bf17d..0aeb93109 100644 --- a/app/models/poll/stats.rb +++ b/app/models/poll/stats.rb @@ -121,7 +121,7 @@ class Poll::Stats stats_cache(*stats_methods) - def stats_cache(key, &) - Rails.cache.fetch("polls_stats/#{poll.id}/#{key}/#{version}", &) + def full_cache_key_for(key) + "polls_stats/#{poll.id}/#{key}/#{version}" end end