Class: Decidim::ParticipatoryProcesses::ParticipatoryProcessStatsPresenter
- Inherits:
-
StatsPresenter
- Object
- SimpleDelegator
- StatsPresenter
- Decidim::ParticipatoryProcesses::ParticipatoryProcessStatsPresenter
- Includes:
- IconHelper
- Defined in:
- decidim-participatory_processes/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb
Overview
A presenter to render statistics in the homepage.
Constant Summary
Constants included from IconHelper
IconHelper::DEFAULT_RESOURCE_TYPE_ICONS
Instance Method Summary collapse
- #card_collection ⇒ Object
-
#collection ⇒ Object
Public: returns a collection of stats (Hash) for the Process Home.
- #participatory_process ⇒ Object
Methods included from IconHelper
#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key
Methods inherited from StatsPresenter
Instance Method Details
#card_collection ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'decidim-participatory_processes/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb', line 27 def card_collection card_stats = Decidim.stats.only([:followers_count, :votings_count]) .filter(priority: StatsRegistry::HIGH_PRIORITY) .with_context(participatory_process) .map { |stat_title, stat_number| [participatory_process.manifest.name, stat_title, stat_number] } statistics(card_stats.group_by(&:first)) end |
#collection ⇒ Object
Public: returns a collection of stats (Hash) for the Process Home.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'decidim-participatory_processes/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb', line 14 def collection highlighted_stats = process_participants_stats highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY)) highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY)) highlighted_stats.concat(comments_stats(:participatory_processes)) 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) end |
#participatory_process ⇒ Object
9 10 11 |
# File 'decidim-participatory_processes/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb', line 9 def participatory_process __getobj__.fetch(:participatory_process) end |