Sha256: 0d3c6b2c7d233031d28e6e7eb066c1500556b2826b8aa7bd256ec5f9e0b09de5

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    class DelegatesVotesByQuestion < Decidim::Query
      def initialize(question)
        @question = question
      end

      def query
        DelegationVotes.new.query
                       .merge(question.votes)
                       .merge(consultation_delegations)
                       .distinct.count(:granter_id)
      end

      private

      attr_reader :question

      def consultation_delegations
        ConsultationDelegations.for(question.consultation)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-action_delegator-0.8.1 app/queries/decidim/action_delegator/delegates_votes_by_question.rb