Sha256: a4f3cb11f988770302dde1229573afe84d905d778b964e7c3a1f5f1b33d66304

Contents?: true

Size: 1.01 KB

Versions: 71

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

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

        def calculate
          meetings = Decidim::Meetings::Meeting.where(component: @resource).joins(:component)

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

          meetings_followers = meetings_followers.where("decidim_follows.created_at >= ?", start_time)
          quantity_users = meetings_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-meetings-0.25.0.rc4 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.25.0.rc3 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.25.0.rc2 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.25.0.rc1 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.3 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.6 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.2 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.5 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.1 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.0 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.0.rc2 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.4 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.24.0.rc1 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.3 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.2 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.1 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.1.rc1 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.23.0 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.22.0 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb
decidim-meetings-0.21.0 app/queries/decidim/meetings/metrics/meeting_followers_metric_measure.rb