Class: Decidim::Debates::Metrics::DebateParticipantsMetricMeasure

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

Overview

Searches for Participants in the following actions

- Create a debate (Debates)

Instance Method Summary collapse

Instance Method Details

#calculateObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb', line 13

def calculate
  debates = Decidim::Debates::Debate.where(component: @resource).joins(:component)
                                    .where("decidim_debates_debates.created_at <= ?", end_time)
                                    .where(decidim_author_type: Decidim::UserBaseEntity.name)
                                    .where.not(author: nil)

  {
    cumulative_users: debates.pluck(:decidim_author_id),
    quantity_users: debates.where("decidim_debates_debates.created_at >= ?", start_time).pluck(:decidim_author_id)
  }
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb', line 9

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