Sha256: 2afddc118702add94cd8a8f19f912805ed9d96ae0e7ec1e34127b91760069471

Contents?: true

Size: 925 Bytes

Versions: 58

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    module Metrics
      # Searches for Participants in the following actions
      #  - Vote a participatory budgeting project (Budgets)
      class BudgetParticipantsMetricMeasure < Decidim::MetricMeasure
        def valid?
          super && @resource.is_a?(Decidim::Component)
        end

        def calculate
          budgets = Decidim::Budgets::Budget.where(component: @resource)
          orders = Decidim::Budgets::Order.where(budget: budgets)
                                          .finished
                                          .where("decidim_budgets_orders.checked_out_at <= ?", end_time)

          {
            cumulative_users: orders.pluck(:decidim_user_id),
            quantity_users: orders.where("decidim_budgets_orders.checked_out_at >= ?", start_time).pluck(:decidim_user_id)
          }
        end
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

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