Class: ParadeDB::SearchMethods::AggregationQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/parade_db/search_methods.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation:, primary_key:, builder:, agg_specs:, exact:, connection:) ⇒ AggregationQuery

Returns a new instance of AggregationQuery.



1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
# File 'lib/parade_db/search_methods.rb', line 1013

def initialize(relation:, primary_key:, builder:, agg_specs:, exact:, connection:)
  @connection = connection
  @agg_specs = agg_specs
  @relation = build_relation(
    relation: relation,
    primary_key: primary_key,
    builder: builder,
    agg_specs: agg_specs,
    exact: exact
  )
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



1000
1001
1002
# File 'lib/parade_db/search_methods.rb', line 1000

def connection
  @connection
end

#relationObject (readonly)

Returns the value of attribute relation.



1000
1001
1002
# File 'lib/parade_db/search_methods.rb', line 1000

def relation
  @relation
end

Class Method Details

.build(relation:, primary_key:, builder:, agg_specs:, exact:, connection:) ⇒ Object



1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'lib/parade_db/search_methods.rb', line 1002

def self.build(relation:, primary_key:, builder:, agg_specs:, exact:, connection:)
  new(
    relation: relation,
    primary_key: primary_key,
    builder: builder,
    agg_specs: agg_specs,
    exact: exact,
    connection: connection
  )
end

Instance Method Details

#executeObject



1029
1030
1031
1032
# File 'lib/parade_db/search_methods.rb', line 1029

def execute
  row = connection.select_one(sql)
  parse_aggregates(row)
end

#sqlObject



1025
1026
1027
# File 'lib/parade_db/search_methods.rb', line 1025

def sql
  relation.to_sql
end