Split common and specific stats methods

This commit is contained in:
Javi Martín
2018-12-13 12:40:41 +01:00
parent 1a86f7dbe8
commit e4a032ee68
2 changed files with 11 additions and 5 deletions

View File

@@ -3,11 +3,11 @@ class Budget::Stats
alias_method :budget, :resource alias_method :budget, :resource
def self.stats_methods def self.stats_methods
%i[total_participants total_participants_support_phase total_participants_vote_phase super +
%i[total_participants_support_phase total_participants_vote_phase
total_budget_investments total_votes total_selected_investments total_budget_investments total_votes total_selected_investments
total_unfeasible_investments total_male_participants total_female_participants total_unfeasible_investments total_supports headings
total_supports total_unknown_gender_or_age age_groups male_percentage total_participants_web total_participants_booths]
female_percentage headings total_participants_web total_participants_booths]
end end
private private

View File

@@ -70,6 +70,12 @@ module Statisticable
end end
class_methods do class_methods do
def stats_methods
%i[total_participants total_male_participants
total_female_participants total_unknown_gender_or_age
male_percentage female_percentage age_groups]
end
def stats_cache(*method_names) def stats_cache(*method_names)
method_names.each do |method_name| method_names.each do |method_name|
alias_method :"raw_#{method_name}", method_name alias_method :"raw_#{method_name}", method_name