Sha256: b9a989d25d39b295142412bc403fe0bcd97e8db20c3b7e8f72e0255c318aae41

Contents?: true

Size: 954 Bytes

Versions: 49

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 < Rectify::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

49 entries across 49 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.9 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.8 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.7 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.5 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.3 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.0 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.0.rc2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.26.0.rc1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.0 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.0.rc4 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.0.rc3 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.0.rc2 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.25.0.rc1 app/queries/decidim/user_groups/accepted_users.rb
decidim-core-0.24.3 app/queries/decidim/user_groups/accepted_users.rb