-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify stats caching #3510
Simplify stats caching #3510
Conversation
total_participants_booth total_booth_valid total_booth_white total_booth_null | ||
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth | ||
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage | ||
null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [104/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
def self.stats_methods | ||
%i[total_participants total_participants_web total_web_valid total_web_white total_web_null | ||
total_participants_booth total_booth_valid total_booth_white total_booth_null | ||
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
end | ||
end | ||
def supports(supportable) | ||
ActsAsVotable::Vote.where(votable_type: "Budget::Investment", votable_id: supportable.investments.pluck(:id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [115/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
percentage_participants_vote_phase: participants_percent(heading_totals, groups_totals, :total_participants_vote_phase), | ||
percentage_district_population_vote_phase: population_percent(population, heading_totals[:total_participants_vote_phase]), | ||
percentage_participants_all_phase: participants_percent(heading_totals, groups_totals, :total_participants_all_phase), | ||
percentage_district_population_all_phase: population_percent(population, heading_totals[:total_participants_all_phase]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [127/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
percentage_district_population_support_phase: population_percent(population, heading_totals[:total_participants_support_phase]), | ||
percentage_participants_vote_phase: participants_percent(heading_totals, groups_totals, :total_participants_vote_phase), | ||
percentage_district_population_vote_phase: population_percent(population, heading_totals[:total_participants_vote_phase]), | ||
percentage_participants_all_phase: participants_percent(heading_totals, groups_totals, :total_participants_all_phase), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [126/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
groups | ||
end | ||
end | ||
groups[:total][:percentage_participants_support_phase] = groups.collect {|_k, v| v[:percentage_participants_support_phase]}.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [133/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
supports(heading).pluck(:voter_id) | ||
end | ||
budget.headings.each do |heading| | ||
groups[heading.id].merge!(calculate_heading_stats_with_totals(groups[heading.id], groups[:total], heading.population)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [126/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum | ||
groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum | ||
groups[:total][:total_participants_vote_phase] = groups.collect {|_k, v| v[:total_participants_vote_phase]}.sum | ||
groups[:total][:total_participants_all_phase] = groups.collect {|_k, v| v[:total_participants_all_phase]}.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [115/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
groups[:total] = Hash.new(0) | ||
groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum | ||
groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum | ||
groups[:total][:total_participants_vote_phase] = groups.collect {|_k, v| v[:total_participants_vote_phase]}.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [117/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
end | ||
groups[:total] = Hash.new(0) | ||
groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum | ||
groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [123/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
d442fe8
to
963b5f8
Compare
24a1288
to
cc84060
Compare
end | ||
end | ||
groups[:total] = Hash.new(0) | ||
groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
stats_cache("balloters") { @budget.ballots.where("ballot_lines_count > ?", 0).pluck(:user_id) } | ||
def balloters_by_heading(heading_id) | ||
stats_cache("balloters_by_heading_#{heading_id}") do | ||
budget.ballots.joins(:lines).where(budget_ballot_lines: {heading_id: heading_id}).pluck(:user_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
cc84060
to
a942e78
Compare
963b5f8
to
b8dbdaf
Compare
a942e78
to
1882782
Compare
References
Objectives
Poll::Stats
andBudget::Stats
so it's easier to read