Sha256: 44349407c03f29df4816eb927827ab45b72cb6cab945b88da32d3e4959f7c231

Contents?: true

Size: 974 Bytes

Versions: 71

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    module Metrics
      # Searches for Participants in the following actions
      #  - Create a debate (Debates)
      class DebateParticipantsMetricMeasure < Decidim::MetricMeasure
        def valid?
          super && @resource.is_a?(Decidim::Component)
        end

        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
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
decidim-debates-0.29.1 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.4 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.27.9 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.29.0 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.3 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.27.8 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.29.0.rc4 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.29.0.rc3 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.29.0.rc2 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.29.0.rc1 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.2 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.27.7 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.1 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.27.6 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.26.10 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.26.9 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.0 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.27.5 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.0.rc5 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb
decidim-debates-0.28.0.rc4 app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb