You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: users_query.rb
    path of file: ./repos/forem/app/queries/admin
    
    the code of the file until where you have to start completion: module Admin
  class UsersQuery
    SEARCH_CLAUSE = "users.name ILIKE :search OR " \
                    "users.email ILIKE :search OR " \
                    "users.username ILIKE :search".freeze

    # @api public
    # @param relation 
    
    def self.filter_roles(relation:, roles:, role_map: Constants::Role::ALL_ROLES_LABELS_TO_WHERE_CLAUSE)
      conditions = []
      values = []

      # Assemble the conditions and positional parameter values
      roles.each do |role|
        where_clause = role_map.fetch(role)

        resource_type = where_clause.fetch(:resource_type, nil)
        name = where_clause.fetch(:name)

        condition = "(#{Role.table_name}.name = ? AND #{Role.table_name}.resource_id IS NULL"
        values << name

        # We need to use `IS NULL` instead of `= NULL` as those are different meanings.
        if resource_type.nil?
          condition += " AND #{Role.table_name}.resource_type IS NULL"
        else
          condition += " AND #{Role.table_name}.resource_type = ?"
          values << resource_type
        end
        condition += ")"
        conditions << condition
      end