Class: Decidim::Proposals::Metrics::ProposalFollowersMetricMeasure

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

Overview

Searches for unique Users following the next objects

- Proposals
- CollaborativeDrafts

Instance Method Summary collapse

Instance Method Details

#calculateObject



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

def calculate
  cumulative_users = []
  cumulative_users |= retrieve_proposals_followers.pluck(:decidim_user_id)
  cumulative_users |= retrieve_drafts_followers.pluck(:decidim_user_id)

  quantity_users = []
  quantity_users |= retrieve_proposals_followers(from_start: true).pluck(:decidim_user_id)
  quantity_users |= retrieve_drafts_followers(from_start: true).pluck(:decidim_user_id)

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

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb', line 10

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