Merge branch '3609-arv-ws' refs #3609
[arvados.git] / services / api / lib / eventbus.rb
index 96e9d043223c2b590255098e9cd32d74d3c1b3b7..bccbeea4bb62ed951cdcc3f6a6ad2d2ac9098d7d 100644 (file)
@@ -78,6 +78,8 @@ class EventBus
           ws.filters.each do |filter|
             ft = record_filters filter.filters, Log
             if ft[:cond_out].any?
+              # Join the clauses within a single subscription filter with AND
+              # so it is consistent with regular queries
               cond_out << "(#{ft[:cond_out].join ') AND ('})"
               param_out += ft[:param_out]
             end
@@ -85,7 +87,8 @@ class EventBus
 
           # Add filters to query
           if cond_out.any?
-            logs = logs.where(cond_id + " AND (#{cond_out.join ') OR ('})", *param_out)
+            # Join subscriptions with OR
+            logs = logs.where(cond_id + " AND ((#{cond_out.join ') OR ('}))", *param_out)
           else
             logs = logs.where(cond_id, *param_out)
           end
@@ -126,7 +129,7 @@ class EventBus
           # Add a filter.  This gets the :filters field which is the same
           # format as used for regular index queries.
           ws.filters << Filter.new(p)
-          ws.send ({status: 200, message: 'subscribe ok'}.to_json)
+          ws.send ({status: 200, message: 'subscribe ok', filter: p}.to_json)
 
           # Send any pending events
           push_events ws