A nice shortcut for group count queries
Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
hightop.gemspec

README.md

Hightop

A nice shortcut for group count queries

Visit.top(:browser)

instead of

Visit.group(:browser).where("browser IS NOT NULL").order("count_all DESC, browser").count

Be sure to sanitize user input like you must with group.

Build Status

Options

Limit the results

Visit.top(:referring_domain, 10)

Include nil values

Visit.top(:search_keyword, nil: true)

Works with multiple groups

Visit.top([:city, :browser])

And expressions

Visit.top(Arel.sql("LOWER(referring_domain)"))

And distinct

Visit.top(:city, distinct: :user_id)

And min count

Visit.top(:city, min: 10)

Installation

Add this line to your application’s Gemfile:

gem 'hightop'

And then execute:

bundle

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: