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 20 21 22 23 24 25 26 27 |
# 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 = highlighted_stats.concat(global_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats = highlighted_stats.reject(&:empty?) highlighted_stats = highlighted_stats.reject { |_name, data| data.zero? } safe_join( highlighted_stats.in_groups_of(2, false).map do |stats| content_tag :div, class: "home-pam__highlight" do safe_join( stats.map do |name, data| render_stats_data(name, data) end ) end end ) end |
#not_highlighted ⇒ Object
Public: Render a collection of stats that are not primary.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/presenters/decidim/home_stats_presenter.rb', line 30 def not_highlighted not_highlighted_stats = global_stats(priority: StatsRegistry::MEDIUM_PRIORITY) not_highlighted_stats = 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? } safe_join( not_highlighted_stats.in_groups_of(3, [:empty]).map do |stats| content_tag :div, class: "home-pam__lowlight" do safe_join( stats.map do |name, data| render_stats_data(name, data) end ) end end ) end |