Class: Parse::SortableGroupByDate

Inherits:
GroupByDate show all
Defined in:
lib/parse/query.rb

Overview

Sortable version of GroupByDate that returns GroupedResult objects instead of plain hashes. Provides the same aggregation methods but with sorting capabilities.

Instance Method Summary collapse

Methods inherited from GroupByDate

#initialize, #order, #pipeline, #sort

Constructor Details

This class inherits a constructor from Parse::GroupByDate

Instance Method Details

#average(field) ⇒ GroupedResult Also known as: avg

Calculate average of a field for each time period.

Parameters:

  • field (Symbol, String)

    the field to average within each time period.

Returns:



7412
7413
7414
7415
# File 'lib/parse/query.rb', line 7412

def average(field)
  results = super
  GroupedResult.new(results, "average")
end

#countGroupedResult

Count the number of items in each time period.

Returns:



7396
7397
7398
7399
# File 'lib/parse/query.rb', line 7396

def count
  results = super
  GroupedResult.new(results, "count")
end

#max(field) ⇒ GroupedResult

Find maximum value of a field for each time period.

Parameters:

  • field (Symbol, String)

    the field to find maximum for within each time period.

Returns:



7430
7431
7432
7433
# File 'lib/parse/query.rb', line 7430

def max(field)
  results = super
  GroupedResult.new(results, "max")
end

#min(field) ⇒ GroupedResult

Find minimum value of a field for each time period.

Parameters:

  • field (Symbol, String)

    the field to find minimum for within each time period.

Returns:



7422
7423
7424
7425
# File 'lib/parse/query.rb', line 7422

def min(field)
  results = super
  GroupedResult.new(results, "min")
end

#sum(field) ⇒ GroupedResult

Sum a field for each time period.

Parameters:

  • field (Symbol, String)

    the field to sum within each time period.

Returns:



7404
7405
7406
7407
# File 'lib/parse/query.rb', line 7404

def sum(field)
  results = super
  GroupedResult.new(results, "sum")
end