hightop 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5b161bc2d5fcb7b053be0581fe018c56fd818a0
4
- data.tar.gz: 304d42b406499cbbd396948e1816369353f889f0
3
+ metadata.gz: 7afed0619ef7e10ad7396edd82f1b7ee4fd76bbd
4
+ data.tar.gz: a490f3b11648fc044a1f1e0b9b52f7686efe7638
5
5
  SHA512:
6
- metadata.gz: 3a47145bd2f6858502a0e02314a04ce0c151924366f4531d15145fc98d171d77ab03dce2cf36bfa5f0a299e100e27d503d100cee8f14a7c4bcbb81b14bd7b9d7
7
- data.tar.gz: d2c71a0da54bb8a9151c6ff71eb70f0587f1282d436b2dc7dd0af7aed8bef528f7bcfe582c454e4f239d20960e83c4a36af6fe012a1372ffefd2df01745b9fb6
6
+ metadata.gz: 8df32f44bc3eb512189840d6fb28b65af553aed3ad946de6e848975f5ad4faf052ef6d95a873217dafdd8ebde3f566eebf9884e3a303adc185746bcd89319315
7
+ data.tar.gz: 53a8a14e86db5f6ded22ef82e8cfea1c52437aaca8ca6219f842b5060281a792d87d1ab52fc1ec9005170a4281c59ec3a9958cd84922e5bc5f8acae4a81c9436
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.2 [unreleased]
2
+
3
+ - Added `min` option
4
+
1
5
  ## 0.1.1
2
6
 
3
7
  - Added `uniq` option
data/README.md CHANGED
@@ -44,6 +44,12 @@ And distinct
44
44
  Visit.top(:city, uniq: :user_id)
45
45
  ```
46
46
 
47
+ And min count
48
+
49
+ ```ruby
50
+ Visit.top(:city, min: 10)
51
+ ```
52
+
47
53
  ## Installation
48
54
 
49
55
  Add this line to your application’s Gemfile:
@@ -1,3 +1,3 @@
1
1
  module Hightop
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/hightop.rb CHANGED
@@ -21,6 +21,10 @@ module Hightop
21
21
  end
22
22
  end
23
23
 
24
+ if options[:min]
25
+ relation = relation.having("COUNT(*) >= #{options[:min].to_i}")
26
+ end
27
+
24
28
  if options[:uniq]
25
29
  relation.uniq.count(options[:uniq])
26
30
  else
data/test/hightop_test.rb CHANGED
@@ -72,6 +72,15 @@ class TestHightop < Minitest::Test
72
72
  assert_equal expected, Visit.top(:city, uniq: :user_id)
73
73
  end
74
74
 
75
+ def test_min
76
+ create_city("San Francisco", 3)
77
+ create_city("Chicago", 2)
78
+ expected = {
79
+ "San Francisco" => 3
80
+ }
81
+ assert_equal expected, Visit.top(:city, min: 3)
82
+ end
83
+
75
84
  def create_city(city, count = 1)
76
85
  create({city: city}, count)
77
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hightop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord