Sha256: 355da727b5018549f8d3121c59d0aa857e19a979c81553df5c0d7a1049d69f30
Contents?: true
Size: 550 Bytes
Versions: 2
Compression:
Stored size: 550 Bytes
Contents
require "hightop/version" module Hightop def top(column, limit = nil, options = {}) if limit.is_a?(Hash) options = limit limit = nil end order_str = column.is_a?(Array) ? column.map(&:to_s).join(", ") : column relation = group(column).limit(limit).order("count_all DESC, #{order_str}") unless options[:nil] (column.is_a?(Array) ? column : [column]).each do |c| relation = relation.where("#{c} IS NOT NULL") end end relation.count end end ActiveRecord::Base.send :extend, Hightop
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hightop-0.1.0 | lib/hightop.rb |
hightop-0.0.4 | lib/hightop.rb |