Sha256: 300f59f13a750ed8084d775464d9aa92c46adde65173d2d438a6c70b2a6b5ad9
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 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.dig(:discussions, :nodes)&.count do |node| !node&.dig(:notes, :nodes, 0, :system) end 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
3 entries across 3 versions & 1 rubygems