Sha256: 36aa8340bfefd664e482fc64e13e60dac670d8e29e7f6ec4d8d0a8fcf753aee9

Contents?: true

Size: 427 Bytes

Versions: 3

Compression:

Stored size: 427 Bytes

Contents

module ActiveReporter
  module Aggregator
    class CountIf < ActiveReporter::Aggregator::Count
      def function
        "COUNT(#{expression} IN (#{values.map(&:to_s).join(",")}) OR NULL)"
      end

      def default_value
        super || 0
      end

      private

      def values
        Array(opts[:values] || opts[:value] || true).compact
      end

      def column
        super || "id"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_reporter-0.7.1 lib/active_reporter/aggregator/count_if.rb
active_reporter-0.6.5 lib/active_reporter/aggregator/count_if.rb
active_reporter-0.6.4 lib/active_reporter/aggregator/count_if.rb