Sha256: c0ee4f546c60663619b51fbcc11bd97011809fba82b05e59282a4735c8253cb3

Contents?: true

Size: 1.01 KB

Versions: 71

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Metrics
      # Searches for unique Users following the next objects
      #  - ParticipatoryProcesses
      class ParticipatoryProcessFollowersMetricMeasure < Decidim::MetricMeasure
        def valid?
          super && @resource.is_a?(Decidim::Participable)
        end

        def calculate
          participatory_process = @resource

          process_followers = Decidim::Follow.where(followable: participatory_process).joins(:user)
                                             .where("decidim_follows.created_at <= ?", end_time)
          cumulative_users = process_followers.pluck(:decidim_user_id)

          process_followers = process_followers.where("decidim_follows.created_at >= ?", start_time)
          quantity_users = process_followers.pluck(:decidim_user_id)

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

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.26.8 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.4 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.3 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.7 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.5 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.2 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.1 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.4 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.0 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.3 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.0.rc2 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.27.0.rc1 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.2 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.1 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.0 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.0.rc2 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.26.0.rc1 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.25.2 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.25.1 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb
decidim-participatory_processes-0.25.0 app/queries/decidim/participatory_processes/metrics/participatory_process_followers_metric_measure.rb