hightop 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +13 -1
- data/lib/hightop/version.rb +1 -1
- data/lib/hightop.rb +16 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846b498786282576ab175fcf91cf24bfb9b86034
|
4
|
+
data.tar.gz: 8392b028241d3b03f59c62dec5b46f694cb8a33d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c1f11dd88fcc63423a3d927c13c2ab4ded446bb062dd104aa2f08d1580bd8dbca9907835aab2cc220e6e06c394747e2f76863c460f029626254d22345715952
|
7
|
+
data.tar.gz: debd4bc6b2a97302db73b08c313a30cfa6825509b838c7bc90acbebb62439518f003108df241b6a52621982f015c319084c17859d5c13afd0b8d248212048274
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -12,13 +12,25 @@ instead of
|
|
12
12
|
Visit.group(:browser).where("browser IS NOT NULL").order("count_all DESC, browser").count
|
13
13
|
```
|
14
14
|
|
15
|
+
Be sure to [sanitize user input](http://rails-sqli.org/) like you must with `group`.
|
16
|
+
|
15
17
|
Limit the results
|
16
18
|
|
17
19
|
```ruby
|
18
20
|
Visit.top(:referring_domain, 10)
|
19
21
|
```
|
20
22
|
|
21
|
-
|
23
|
+
Include nil values
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Visit.top(:referring_domain, nil: true)
|
27
|
+
```
|
28
|
+
|
29
|
+
Works with multiple groups
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Visit.top([:city, :referring_domain])
|
33
|
+
```
|
22
34
|
|
23
35
|
## Installation
|
24
36
|
|
data/lib/hightop/version.rb
CHANGED
data/lib/hightop.rb
CHANGED
@@ -2,9 +2,22 @@ require "hightop/version"
|
|
2
2
|
|
3
3
|
module Hightop
|
4
4
|
|
5
|
-
def top(column, limit = nil)
|
6
|
-
|
7
|
-
|
5
|
+
def top(column, limit = nil, options = {})
|
6
|
+
if limit.is_a?(Hash)
|
7
|
+
options = limit
|
8
|
+
limit = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
order_str = column.is_a?(Array) ? column.map(&:to_s).join(", ") : column
|
12
|
+
relation = group(column).limit(limit).order("count_all DESC, #{order_str}")
|
13
|
+
|
14
|
+
unless options[:nil]
|
15
|
+
(column.is_a?(Array) ? column : [column]).each do |c|
|
16
|
+
relation = relation.where("#{c} IS NOT NULL")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
relation.count
|
8
21
|
end
|
9
22
|
|
10
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hightop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|