Sha256: 82c0d57eda603a0fb2f8d5cf83c38fc1cfbea7c4afc00ea6ccd09fffc5ab2920

Contents?: true

Size: 1.06 KB

Versions: 44

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module Metrics
      class AcceptedProposalsMetricManage < Decidim::Proposals::Metrics::ProposalsMetricManage
        def metric_name
          "accepted_proposals"
        end

        private

        def query
          return @query if @query

          spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
            manifest.participatory_spaces.call(@organization).public_spaces
          end
          @query = Decidim::Proposals::Proposal.where(component: visible_components_from_spaces(spaces)).joins(:component)
                                               .left_outer_joins(:category)
          @query = @query.where("decidim_proposals_proposals.created_at <= ?", end_time).accepted
          @query = @query.group("decidim_categorizations.id", :participatory_space_type, :participatory_space_id)
          @query
        end

        def quantity
          @quantity ||= query.where("decidim_proposals_proposals.created_at >= ?", start_time).count
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

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