summaryrefslogtreecommitdiff
path: root/app/finders/union_finder.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-03-20 21:03:53 +0100
committerDouwe Maan <douwe@selenight.nl>2016-03-20 21:04:07 +0100
commit8db1292139cfdac4c29c03b876b68b9e752cf75a (patch)
tree2fcf67ada482ecf4ac90f39c858334a62b709618 /app/finders/union_finder.rb
parent2eb19ea3ea36916bbea72a8ccab3e6d15f602ac9 (diff)
downloadgitlab-ce-8db1292139cfdac4c29c03b876b68b9e752cf75a.tar.gz
Tweaks, refactoring, and specs
Diffstat (limited to 'app/finders/union_finder.rb')
-rw-r--r--app/finders/union_finder.rb11
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