Sha256: 5a56b30139f0c40b2f5d0d9550238a77edd1e1c89eb430f074a5cb8cdc2aa03f

Contents?: true

Size: 1.34 KB

Versions: 26

Compression:

Stored size: 1.34 KB

Contents

require_relative 'base_conditions_filter'

module Gitlab
  module Triage
    module Filters
      class DiscussionsConditionsFilter < BaseConditionsFilter
        ATTRIBUTES = %w[notes threads].freeze
        CONDITIONS = %w[greater_than less_than].freeze

        def self.filter_parameters
          [
            {
              name: :attribute,
              type: String,
              values: ATTRIBUTES
            },
            {
              name: :condition,
              type: String,
              values: CONDITIONS
            },
            {
              name: :threshold,
              type: Numeric
            }
          ]
        end

        def initialize_variables(condition)
          @attribute = condition[:attribute].to_sym
          @condition = condition[:condition].to_sym
          @threshold = condition[:threshold]
        end

        def resource_value
          if @attribute == :notes
            @resource[:user_notes_count]
          else
            @resource[:user_discussions_count]
          end
        end

        def condition_value
          @threshold
        end

        def calculate
          case @condition
          when :greater_than
            resource_value.to_i > condition_value
          when :less_than
            resource_value.to_i < condition_value
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
gitlab-triage-1.42.2 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.42.1 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.42.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.41.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.40.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.30.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.29.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
payping-gitlab-triage-0.1.3 lib/gitlab/triage/filters/discussions_conditions_filter.rb
payping-gitlab-triage-0.1.2 lib/gitlab/triage/filters/discussions_conditions_filter.rb
payping-gitlab-triage-0.1.1 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.28.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.27.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.26.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.25.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.24.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.23.1 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.23.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.22.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.21.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb
gitlab-triage-1.20.0 lib/gitlab/triage/filters/discussions_conditions_filter.rb