Sha256: 23abd15cf569b5e9b65ecab7cb5cdbfacbd8383b708c103c7be82e82b8ba9e5a
Contents?: true
Size: 759 Bytes
Versions: 1
Compression:
Stored size: 759 Bytes
Contents
module Aggrobot module QueryPlanner class DefaultQueryPlanner include Aggrobot::Helper def initialize(collection, group) @collection, @group = collection, group end def sub_query(group_name) @group == DEFAULT_GROUP_BY ? @collection : @collection.where(@group => group_name) end def query_results(extra_cols = []) return [] if collection_is_none? columns = [@group, SqlFunctions.count] + extra_cols results_query.pluck(*columns) end protected def results_query @result_query ||= @collection.group(@group) end def collection_is_none? @collection.extending_values.include?(ActiveRecord::NullRelation) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aggrobot-0.0.2 | lib/aggrobot/query_planner/default_query_planner.rb |