Class: Decidim::Comments::Metrics::CommentParticipantsMetricMeasure

Inherits:
MetricMeasure
  • Object
show all
Defined in:
decidim-comments/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb

Overview

Searches for Participants in the following actions

- Leave a comment (Comments)

Instance Method Summary collapse

Methods inherited from MetricMeasure

#initialize

Constructor Details

This class inherits a constructor from Decidim::MetricMeasure

Instance Method Details

#calculateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'decidim-comments/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb', line 13

def calculate
  cumulative_users = []
  quantity_users = []

  retrieve_comments_for_organization.each do |comment|
    related_object = comment.root_commentable
    next unless related_object
    next unless check_participatory_space(@resource, related_object)

    cumulative_users << comment.decidim_author_id
    quantity_users << comment.decidim_author_id if comment.created_at >= start_time
  end
  {
    cumulative_users: cumulative_users.uniq,
    quantity_users: quantity_users.uniq
  }
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'decidim-comments/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb', line 9

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