Welcome to mirror list, hosted at ThFree Co, Russian Federation.

union_finder.rb « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 798c3eba0f3fae582ad4a0eb58cff32c3bb658cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class UnionFinder
  # rubocop: disable CodeReuse/ActiveRecord
  def find_union(segments, klass)
    if segments.length > 1
      union = Gitlab::SQL::Union.new(segments.map { |s| s.select(:id) })

      klass.where("#{klass.table_name}.id IN (#{union.to_sql})")
    else
      segments.first
    end
  end
  # rubocop: enable CodeReuse/ActiveRecord
end