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: 91b845871a82ea650a85c1408bcd199f7bdbd0ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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