Sha256: 4469450403227fe0c16a8db2ff5d5b1cb721415b569123dbc0d8b9e79cc90403

Contents?: true

Size: 830 Bytes

Versions: 38

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # Class uses to retrieve initiatives promoted by the given  user
    class InitiativesPromoted < Rectify::Query
      attr_reader :user

      # Syntactic sugar to initialize the class and return the queried objects.
      #
      # user - Decidim::User
      def self.by(user)
        new(user).query
      end

      # Initializes the class.
      #
      # user: Decidim::User
      def initialize(user)
        @user = user
      end

      # Retrieves the initiatives promoted by the  given  user.
      def query
        Initiative
          .joins(:committee_members)
          .where("decidim_initiatives_committee_members.state = 2")
          .where("decidim_initiatives_committee_members.decidim_users_id = ?", user.id)
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-initiatives-0.23.6 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.5 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.4 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.3 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.2 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.1.rc1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.23.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.22.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.21.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.20.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.20.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.19.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.18.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.19.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.17.2 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.18.0 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.17.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.16.1 app/queries/decidim/initiatives/initiatives_promoted.rb
decidim-initiatives-0.17.0 app/queries/decidim/initiatives/initiatives_promoted.rb