Class: Decidim::ParticipatoryProcesses::ParticipatoryProcessStatsPresenter
- Inherits:
-
Rectify::Presenter
- Object
- Rectify::Presenter
- Decidim::ParticipatoryProcesses::ParticipatoryProcessStatsPresenter
- Includes:
- IconHelper
- Defined in:
- app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb
Overview
A presenter to render statistics in the homepage.
Instance Method Summary collapse
-
#collection ⇒ Object
Public: returns a collection of stats (Hash) for the Process Home.
Instance Method Details
#collection ⇒ Object
Public: returns a collection of stats (Hash) for the Process Home.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb', line 11 def collection highlighted_stats = process_participants_stats highlighted_stats = highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY)) highlighted_stats = highlighted_stats.reject(&:empty?) highlighted_stats = highlighted_stats.reject { |_stat_manifest, _stat_title, stat_number| stat_number.zero? } grouped_highlighted_stats = highlighted_stats.group_by(&:first) statistics = [] grouped_highlighted_stats.each do |_manifest_name, stats| stats.each_with_index.each do |stat, _index| stat.each_with_index.map do |_item, subindex| next unless (subindex % 3).zero? next if stat[subindex + 2].zero? statistics << { stat_title: stat[subindex + 1], stat_number: stat[subindex + 2] } end end end statistics end |