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
.
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("LOWER(referring_domain)")
And distinct
Visit.top(:city, uniq: :user_id)
And min count [master]
Visit.top(:city, min: 10)
Add this line to your application’s Gemfile:
gem 'hightop'
And then execute:
bundle
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features