Sha256: fec458407b1b0d16e49c502d1cfde07141b4c5fdb98ce24d65198cd8d41e295e
Contents?: true
Size: 1.8 KB
Versions: 23
Compression:
Stored size: 1.8 KB
Contents
require_relative 'base_conditions_filter' module Gitlab module Triage module Filters class MergeRequestDateConditionsFilter < BaseConditionsFilter ATTRIBUTES = %w[merged_at].freeze CONDITIONS = %w[older_than newer_than].freeze INTERVAL_TYPES = %w[days weeks months years].freeze def self.allowed_attributes self::ATTRIBUTES end def self.filter_parameters [ { name: :attribute, type: String, values: allowed_attributes }, { name: :condition, type: String, values: CONDITIONS }, { name: :interval_type, type: String, values: INTERVAL_TYPES }, { name: :interval, type: Numeric } ] end def initialize_variables(condition) @attribute = condition[:attribute].to_sym @condition = condition[:condition].to_sym @interval_type = condition[:interval_type].to_sym @interval = condition[:interval] end # Guard against merge requests with no merged_at values def resource_value @resource[@attribute]&.to_date end def condition_value @interval.public_send(@interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend end # Guard against merge requests with no merged_at values def calculate return false unless resource_value case @condition when :older_than resource_value < condition_value when :newer_than resource_value > condition_value end end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems