Class: Decidim::ParticipatoryProcessStatsPresenter

Inherits:
Rectify::Presenter
  • Object
show all
Includes:
IconHelper
Defined in:
decidim-core/app/presenters/decidim/participatory_process_stats_presenter.rb

Overview

A presenter to render statistics in the homepage.

Instance Method Summary collapse

Methods included from IconHelper

#feature_icon, #feature_manifest_icon

Instance Method Details

#highlightedObject

Public: Render a collection of primary stats.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-core/app/presenters/decidim/participatory_process_stats_presenter.rb', line 10

def highlighted
  highlighted_stats = feature_stats(priority: StatsRegistry::HIGH_PRIORITY)
  highlighted_stats = highlighted_stats.concat(feature_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
  highlighted_stats = highlighted_stats.reject(&:empty?)
  highlighted_stats = highlighted_stats.reject { |_manifest, _name, data| data.zero? }
  grouped_highlighted_stats = highlighted_stats.group_by { |stats| stats.first.name }

  safe_join(
    grouped_highlighted_stats.map do |_manifest_name, stats|
       :div, class: "process_stats-item" do
        safe_join(
          stats.each_with_index.map do |stat, index|
            render_stats_data(stat[0], stat[1], stat[2], index)
          end
        )
      end
    end
  )
end