Sha256: e53929bbe4a53719d76e86160c43f6b75c0a8d63075e5fd0da31466d4486a03d
Contents?: true
Size: 1.36 KB
Versions: 19
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module Decidim module Conferences # A presenter to render statistics in the homepage. class ConferenceStatsPresenter < Decidim::StatsPresenter attribute :conference, Decidim::Conference include IconHelper # Public: Render a collection of primary stats. def highlighted highlighted_stats = component_stats(priority: StatsRegistry::HIGH_PRIORITY) highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY)) highlighted_stats.concat(comments_stats(:conferences)) highlighted_stats = highlighted_stats.reject(&:empty?) highlighted_stats = highlighted_stats.reject { |_manifest, _name, data| data.zero? } grouped_highlighted_stats = highlighted_stats.group_by(&:first) statistics(grouped_highlighted_stats) end private def component_stats(conditions) Decidim.component_manifests.map do |component_manifest| component_manifest.stats .filter(conditions) .with_context(published_components) .map { |name, data| [component_manifest.name, name, data] }.flatten end end def published_components @published_components ||= Component.where(participatory_space: conference).published end end end end
Version data entries
19 entries across 19 versions & 1 rubygems