Class: Decidim::Proposals::Metrics::ProposalParticipantsMetricMeasure

Inherits:
MetricMeasure
  • Object
show all
Defined in:
app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb

Overview

Searches for Participants in the following actions

- Create a proposal (Proposals)
- Vote to a proposal (Proposals)
- Endorse (Proposals)

Instance Method Summary collapse

Instance Method Details

#calculateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb', line 15

def calculate
  cumulative_users = []
  cumulative_users |= retrieve_votes.pluck(:decidim_author_id)
  cumulative_users |= retrieve_endorsements.pluck(:decidim_author_id)
  cumulative_users |= retrieve_proposals.pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguousness must be called this way

  quantity_users = []
  quantity_users |= retrieve_votes(from_start: true).pluck(:decidim_author_id)
  quantity_users |= retrieve_endorsements(from_start: true).pluck(:decidim_author_id)
  quantity_users |= retrieve_proposals(from_start: true).pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguousness must be called this way

  {
    cumulative_users: cumulative_users.uniq,
    quantity_users: quantity_users.uniq
  }
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb', line 11

def valid?
  super && @resource.is_a?(Decidim::Component)
end