Extract method to get the stats key in stats
This way we remove a bit of duplication and it'll be easier to change the `stats_cache` method.
This commit is contained in:
@@ -192,7 +192,7 @@ class Budget::Stats
|
|||||||
|
|
||||||
stats_cache(*stats_methods)
|
stats_cache(*stats_methods)
|
||||||
|
|
||||||
def stats_cache(key, &)
|
def full_cache_key_for(key)
|
||||||
Rails.cache.fetch("budgets_stats/#{budget.id}/#{phases.join}/#{key}/#{version}", &)
|
"budgets_stats/#{budget.id}/#{phases.join}/#{key}/#{version}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -224,4 +224,8 @@ module Statisticable
|
|||||||
I18n.t("stats.age_range", start: start, finish: finish)
|
I18n.t("stats.age_range", start: start, finish: finish)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stats_cache(key, &)
|
||||||
|
Rails.cache.fetch(full_cache_key_for(key), &)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class Poll::Stats
|
|||||||
|
|
||||||
stats_cache(*stats_methods)
|
stats_cache(*stats_methods)
|
||||||
|
|
||||||
def stats_cache(key, &)
|
def full_cache_key_for(key)
|
||||||
Rails.cache.fetch("polls_stats/#{poll.id}/#{key}/#{version}", &)
|
"polls_stats/#{poll.id}/#{key}/#{version}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user