Class: Decidim::HomeStatsPresenter
- Inherits:
-
Rectify::Presenter
- Object
- Rectify::Presenter
- Decidim::HomeStatsPresenter
- Defined in:
- app/presenters/decidim/home_stats_presenter.rb
Overview
A presenter to render statistics in the homepage.
Instance Method Summary collapse
-
#highlighted ⇒ Object
Public: Render a collection of primary stats.
-
#not_highlighted ⇒ Object
Public: Render a collection of stats that are not primary.
Instance Method Details
#highlighted ⇒ Object
Public: Render a collection of primary stats.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/presenters/decidim/home_stats_presenter.rb', line 9 def highlighted highlighted_stats = Decidim.stats.only([:users_count, :processes_count]).with_context(organization).map { |name, data| [name, data] } highlighted_stats.concat(global_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats = highlighted_stats.reject(&:empty?) highlighted_stats = highlighted_stats.reject { |_name, data| data.zero? } highlighted_stats.map do |name, data| { stat_title: name, stat_number: data } end end |
#not_highlighted ⇒ Object
Public: Render a collection of stats that are not primary.
22 23 24 25 26 27 28 29 30 31 |
# File 'app/presenters/decidim/home_stats_presenter.rb', line 22 def not_highlighted not_highlighted_stats = global_stats(priority: StatsRegistry::MEDIUM_PRIORITY) not_highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY)) not_highlighted_stats = not_highlighted_stats.reject(&:empty?) not_highlighted_stats = not_highlighted_stats.reject { |_name, data| data.zero? } not_highlighted_stats.map do |name, data| { stat_title: name, stat_number: data } end end |