Method: ATSD::SeriesQuery#execute_with
- Defined in:
- lib/atsd/queries/series_query.rb
#execute_with(*others) ⇒ Array<Series>
Executes multiple queries at the same time. Adds request_id parameter to each query if necessary. All queries will have a corresponding series attribute set.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/atsd/queries/series_query.rb', line 41 def execute_with(*others) others ||= [] queries = [self] + others queries_by_id = {} if queries.count > 1 queries.each_with_index do |query, index| query.request_id("query_#{index}") query.result = [] queries_by_id[query[:request_id]] = query end end results = @client.series_query queries.map {|q| q.to_request_hash} results.map! { |json| Series.new(json) } results.each { |r| queries_by_id[r.requestId].result << r } end |