Sha256: 7e2ef23a8ee464f5b2be8374481d674d6b0ace0a580e70f70634eeaec664e97a

Contents?: true

Size: 954 Bytes

Versions: 25

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module UserGroups
    # Use this class to find the accepted members of the given user group.
    class AcceptedUsers < Decidim::Query
      # Syntactic sugar to initialize the class and return the queried objects.
      #
      # user_group - a UserGroup that needs to find its accepted members
      def self.for(user_group)
        new(user_group).query
      end

      # Initializes the class.
      #
      # user_group - a UserGroup that needs to find its accepted members
      def initialize(user_group)
        @user_group = user_group
      end

      # Finds the accepted members of the user group.
      #
      # Returns an ActiveRecord::Relation.
      def query
        user_group
          .users
          .includes(:memberships)
          .where(decidim_user_group_memberships: { role: %w(creator admin member) })
      end

      private

      attr_reader :user_group
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.9 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.29.0 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.3 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.8 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.29.0.rc4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.29.0.rc3 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.29.0.rc2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.29.0.rc1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.7 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.6 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.0 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.5 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.0.rc5 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.28.0.rc4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.27.3 app/queries/decidim/user_groups/accepted_users.rb