Sha256: b03bf34e15e603b4737f1285d6cb2af186cc14349e265277a4c2d4a3ea8a2f03

Contents?: true

Size: 390 Bytes

Versions: 10

Compression:

Stored size: 390 Bytes

Contents

module ActiveReporter
  module Aggregator
    class Count < ActiveReporter::Aggregator::Base
      def function
        "COUNT(#{'DISTINCT' if distinct} #{expression})"
      end

      def default_value
        super || 0
      end

      private

      def distinct
        opts[:distinct] || true
      end

      def column
        opts.fetch(:column, 'id')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active_reporter-0.6.3 lib/active_reporter/aggregator/count.rb
active_reporter-0.6.2 lib/active_reporter/aggregator/count.rb
active_reporter-0.6.1 lib/active_reporter/aggregator/count.rb
active_reporter-0.6.0 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.13 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.12 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.11 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.10 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.9 lib/active_reporter/aggregator/count.rb
active_reporter-0.5.8 lib/active_reporter/aggregator/count.rb