Class: ForestAdminDatasourceZendesk::Collections::BaseCollection

Inherits:
ForestAdminDatasourceToolkit::Collection
  • Object
show all
Defined in:
lib/forest_admin_datasource_zendesk/collections/base_collection.rb

Direct Known Subclasses

Organization, Ticket, User

Constant Summary collapse

ColumnSchema =
ForestAdminDatasourceToolkit::Schema::ColumnSchema
Operators =
ForestAdminDatasourceToolkit::Components::Query::ConditionTree::Operators
Leaf =
ForestAdminDatasourceToolkit::Components::Query::ConditionTree::Nodes::ConditionTreeLeaf
STRING_OPS =
[Operators::EQUAL, Operators::NOT_EQUAL, Operators::IN, Operators::NOT_IN,
Operators::PRESENT, Operators::BLANK].freeze
NUMBER_OPS =
(STRING_OPS + [Operators::GREATER_THAN, Operators::LESS_THAN]).freeze
DATE_OPS =
[Operators::EQUAL, Operators::BEFORE, Operators::AFTER,
Operators::PRESENT, Operators::BLANK].freeze

Instance Method Summary collapse

Instance Method Details

#aggregate(caller, filter, aggregation, _limit = nil) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/forest_admin_datasource_zendesk/collections/base_collection.rb', line 14

def aggregate(caller, filter, aggregation, _limit = nil)
  unless aggregation.operation == 'Count' && aggregation.field.nil? && aggregation.groups.empty?
    raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
          'Zendesk datasource only supports Count aggregation without groups.'
  end

  [{ 'value' => aggregate_count(caller, filter), 'group' => {} }]
end