Class: Orchestrate::Search::TimeSeriesBuilder

Inherits:
Object
  • Object
show all
Includes:
AggregateBuilderDelegator, QueryBuilderDelegator
Defined in:
lib/orchestrate/search/aggregate_builder.rb

Overview

Time Series Builder object for constructing time series functions for the aggregate param

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, field_name) ⇒ TimeSeriesBuilder

Initialize a new TimeSeriesBuilder object

Parameters:

  • builder (AggregateBuilder)

    The Aggregate Builder object

  • field_name (#to_s)

    The field to operate over



250
251
252
253
254
255
# File 'lib/orchestrate/search/aggregate_builder.rb', line 250

def initialize(builder, field_name)
  @builder = builder
  @field_name = field_name
  @interval = nil
  @time_zone = nil
end

Instance Attribute Details

#builderAggregateBuilder (readonly)

Returns:



239
240
241
# File 'lib/orchestrate/search/aggregate_builder.rb', line 239

def builder
  @builder
end

#field_name#to_s (readonly)

Returns The field to operate over.

Returns:

  • (#to_s)

    The field to operate over



242
243
244
# File 'lib/orchestrate/search/aggregate_builder.rb', line 242

def field_name
  @field_name
end

#interval#to_s (readonly)

Returns The interval of time for the TimeSeries function.

Returns:

  • (#to_s)

    The interval of time for the TimeSeries function



245
246
247
# File 'lib/orchestrate/search/aggregate_builder.rb', line 245

def interval
  @interval
end

Instance Method Details

#dayAggregateBuilder

Set time series interval to day

Returns:



302
303
304
305
# File 'lib/orchestrate/search/aggregate_builder.rb', line 302

def day
  @interval = 'day'
  self
end

#hourAggregateBuilder

Set time series interval to hour

Returns:



309
310
311
312
# File 'lib/orchestrate/search/aggregate_builder.rb', line 309

def hour
  @interval = 'hour'
  self
end

#monthAggregateBuilder

Set time series interval to month

Returns:



288
289
290
291
# File 'lib/orchestrate/search/aggregate_builder.rb', line 288

def month
  @interval = 'month'
  self
end

#quarterAggregateBuilder

Set time series interval to quarter

Returns:



281
282
283
284
# File 'lib/orchestrate/search/aggregate_builder.rb', line 281

def quarter
  @interval = 'quarter'
  self
end

#time_zone(zone) ⇒ RangeBuilder

Use the designated time zone (e.g., "-0500" or "+0430") when calculating bucket boundaries

Parameters:

  • zone (String)

Returns:



317
318
319
320
# File 'lib/orchestrate/search/aggregate_builder.rb', line 317

def time_zone(zone)
  @time_zone = zone
  self
end

#to_param#to_s

Returns constructed aggregate string clause.

Returns:

  • (#to_s)

    constructed aggregate string clause



264
265
266
267
268
269
270
# File 'lib/orchestrate/search/aggregate_builder.rb', line 264

def to_param
  if @time_zone.nil?
    "#{field_name}:time_series:#{interval}"
  else
    "#{field_name}:time_series:#{interval}:#{@time_zone}"
  end
end

#to_sObject Also known as: inspect

Returns Pretty-Printed string representation of the TimeSeriesBuilder object.

Returns:

  • Pretty-Printed string representation of the TimeSeriesBuilder object



258
259
260
# File 'lib/orchestrate/search/aggregate_builder.rb', line 258

def to_s
  "#<Orchestrate::Search::TimeSeriesBuilder collection=#{collection.name} field_name=#{field_name} interval=#{interval} time_zone=#{@time_zone}>"
end

#weekAggregateBuilder

Set time series interval to week

Returns:



295
296
297
298
# File 'lib/orchestrate/search/aggregate_builder.rb', line 295

def week
  @interval = 'week'
  self
end

#yearAggregateBuilder

Set time series interval to year

Returns:



274
275
276
277
# File 'lib/orchestrate/search/aggregate_builder.rb', line 274

def year
  @interval = 'year'
  self
end