Class: ATSD::SeriesQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/atsd/queries/series_query.rb

Overview

Class for building and executing Series Query

Constant Summary

Constants inherited from BaseQuery

BaseQuery::TO_MILLISECONDS_LAMBDA

Instance Attribute Summary

Attributes inherited from BaseQuery

#client

Instance Method Summary collapse

Methods inherited from BaseQuery

#initialize, #to_request_hash, #type

Constructor Details

This class inherits a constructor from ATSD::BaseQuery

Instance Method Details

#executeArray<Series>

Executes query and sets ‘result` attribute.

Returns:



30
31
32
33
# File 'lib/atsd/queries/series_query.rb', line 30

def execute
  result = @client.series_query to_request_hash
  @result = result.map { |series_json| Series.new series_json }
end

#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.

Parameters:

  • others (SeriesQuery)

    list of series query to execute with receiver

Returns:

  • (Array<Series>)

    all results



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}") unless query.request_id
      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.request_id].result << r }
end

#resultArray<Series>

Returns:



12
13
14
# File 'lib/atsd/queries/series_query.rb', line 12

def result
  super
end

#tag_add(name, values) ⇒ self

Add tag to ‘tags` parameter

Parameters:

  • name (String)

    tag name

  • values (String, Array<String>)

    possible tag value of array of values. ‘*` and `?` wildcards allowed.

Returns:

  • (self)


22
23
24
25
# File 'lib/atsd/queries/series_query.rb', line 22

def tag_add(name, values)
  self[:tags][name] = Utils.ensure_array(values)
  self
end