diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-03-20 21:03:53 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-03-20 21:04:07 +0100 |
commit | 8db1292139cfdac4c29c03b876b68b9e752cf75a (patch) | |
tree | 2fcf67ada482ecf4ac90f39c858334a62b709618 /app/finders/union_finder.rb | |
parent | 2eb19ea3ea36916bbea72a8ccab3e6d15f602ac9 (diff) | |
download | gitlab-ce-8db1292139cfdac4c29c03b876b68b9e752cf75a.tar.gz |
Tweaks, refactoring, and specs
Diffstat (limited to 'app/finders/union_finder.rb')
-rw-r--r-- | app/finders/union_finder.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/finders/union_finder.rb b/app/finders/union_finder.rb new file mode 100644 index 00000000000..33cd1a491f3 --- /dev/null +++ b/app/finders/union_finder.rb @@ -0,0 +1,11 @@ +class UnionFinder + 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 +end |