Sha256: 80ea1a669e3a7bce8f48a55f81afc3bff414aaf008f895bcb99b33409f583f5b

Contents?: true

Size: 427 Bytes

Versions: 10

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

10 entries across 10 versions & 1 rubygems

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