Sha256: c84a448b43d42f1c4708ef1f1070f9cc189112aee6099c3f1c698faf72c7259b

Contents?: true

Size: 575 Bytes

Versions: 7

Compression:

Stored size: 575 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    class DelegatesVotesByQuestion < Rectify::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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-action_delegator-0.7.2 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.7.1 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.7.0 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.6.0 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.5.0 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.4.1 app/queries/decidim/action_delegator/delegates_votes_by_question.rb
decidim-action_delegator-0.4 app/queries/decidim/action_delegator/delegates_votes_by_question.rb