# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      module Security
        class VulnerabilityReportsComparer
          include Gitlab::Utils::StrongMemoize

          attr_reader :base_report, :head_report

          def initialize(base_report, head_report)
            @base_report = base_report || []
            @head_report = head_report
          end

          def added
            strong_memoize(:added) do
              head_report - base_report
            end
          end

          def fixed
            strong_memoize(:fixed) do
              base_report - head_report
            end
          end

          def existing
            strong_memoize(:existing) do
              base_report & head_report
            end
          end
        end
      end
    end
  end
end
