Class: Decidim::ParticipatoryProcesses::ParticipatoryProcessMetricChartsPresenter

Inherits:
MetricChartsPresenter
  • Object
show all
Defined in:
app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb

Overview

A presenter to render metrics in ParticipatoryProcesses statistics page

Instance Method Summary collapse

Instance Method Details

#big_statsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 24

def big_stats
  safe_join(
    Decidim.metrics_registry.filtered(scope: "participatory_process", block: "big", sort: true).map do |metric_manifest|
       :div, class: "row" do
        render_metrics_descriptive(metric_manifest.metric_name,
                                   klass: "column",
                                   graph_klass: "small",
                                   title: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.title"),
                                   description: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.description"),
                                   download: true,
                                   data: { ratio: "11:4", axis: true })
      end
    end
  )
end

#highlightedObject



16
17
18
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 16

def highlighted
  render_highlighted(Decidim.metrics_registry.filtered(highlight: true, scope: "participatory_process"))
end

#medium_statsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 40

def medium_stats
  safe_join(
    Decidim.metrics_registry.filtered(scope: "participatory_process", block: "medium", sort: true).in_groups_of(2).map do |metrics_group|
       :div, class: "row" do
        safe_join(
          metrics_group.map do |metric_manifest|
            next "" if metric_manifest.blank?

            render_metrics_descriptive(metric_manifest.metric_name,
                                       klass: "column medium-6",
                                       graph_klass: "small",
                                       title: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.title"),
                                       description: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.description"),
                                       download: true,
                                       data: { ratio: "16:9", axis: true })
          end
        )
      end
    end
  )
end

#not_highlightedObject



20
21
22
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 20

def not_highlighted
  render_not_highlighted(Decidim.metrics_registry.filtered(highlight: false, scope: "participatory_process"))
end

#paramsObject



9
10
11
12
13
14
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 9

def params
  capture do
    concat((:input, nil, type: :hidden, id: :"metrics-space_type", value: participatory_process.class))
    concat((:input, nil, type: :hidden, id: :"metrics-space_id", value: participatory_process.id))
  end
end

#small_statsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb', line 62

def small_stats
  safe_join(
    Decidim.metrics_registry.filtered(scope: "participatory_process", block: "small", sort: true).in_groups_of(3).map do |metrics_group|
       :div, class: "row" do
        safe_join(
          metrics_group.map do |metric_manifest|
            next "" if metric_manifest.blank?

            render_metrics_data(metric_manifest.metric_name,
                                klass: "column medium-4",
                                ratio: "16:9",
                                margin: "margin-top: 30px",
                                graph_klass: "small",
                                download: true,
                                data: { ratio: "16:9" })
          end
        )
      end
    end
  )
end