quick_count 0.0.5 → 0.0.6

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
- SHA1:
3
- metadata.gz: d79ddb48bd32a0ee00e718670b816c29be00b385
4
- data.tar.gz: 69f96168ff9a4e23fc2848acb78ba349aee3e305
2
+ SHA256:
3
+ metadata.gz: 13b6d1774446b930452cb50814ff1081c01353f0136f1b60706f57481bfe5e7f
4
+ data.tar.gz: 2cda68595ddd0c78af1b7baacf67639011803d073d72e98a38a030d15df17fef
5
5
  SHA512:
6
- metadata.gz: 0a67dcad3ad203fe9ef2d3e45aeb25b876e095eac05afbb80258ad9b2fccd37cab58e5bdf3a6bc64df900797fa167ae17397b86fe56cffe46f7d28a8b36595ec
7
- data.tar.gz: 2870f889dbd4f7ba5359f4131e3d83ec3a5348c4b89e5a95ed0eb082919da93906253ea7bda30a540bf389e50c09edc78a4aa91421b63d8994fd5c9ebb3c7540
6
+ metadata.gz: 0b2fd37276fbcff9a6dcc0892908389f0f6dbd228133f52e20bd380eb8b66dc446ea597e98d68f9955b3fbb14b5040f38d84d396efc909bc8b332e28154acd38
7
+ data.tar.gz: 49a10a20fbd02043c36978c97dbcd9c744bea945cc8166fd3e0ecb5083364c4f2b2f5f3d2dd93a11068e854197b1f84aecd3c06aeaeda2589fb4a382edffdb2c
data/.gitignore CHANGED
@@ -1,9 +1,75 @@
1
- /.bundle/
2
- /.yardoc
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Database config and secrets
8
+ /config/database.yml
9
+ /config/secrets.yml
10
+
11
+ # Ignore bundler config
12
+ /.bundle
13
+
14
+ # Ignore the default SQLite database.
15
+ /db/*.sqlite3
16
+
17
+ # Ignore all logfiles and tempfiles.
18
+ /log/*.log
19
+ /tmp
20
+ /db/structure.sql
21
+ /doc/app/*
22
+ /vendor/cldr/*
23
+ /public/uploads/*
24
+ /public/photo/*
25
+ /public/test/*
26
+ /test/assets/*
27
+ /spec/assets/*
28
+ /public/assets/**
29
+ .powenv
30
+ .rvmrc
31
+ .env
32
+ .ruby-version
33
+
34
+ # Compiled source #
35
+ ###################
36
+ /pkg
37
+ *.com
38
+ *.class
39
+ *.dll
40
+ *.exe
41
+ *.o
42
+ *.so
43
+
44
+ # Packages #
45
+ ############
46
+ # it's better to unpack these files and commit the raw source
47
+ # git has its own built in compression methods
48
+ *.7z
49
+ *.dmg
50
+ *.gz
51
+ *.iso
52
+ *.jar
53
+ *.rar
54
+ *.tar
55
+ *.zip
56
+
57
+ # Logs and databases #
58
+ ######################
59
+ *.log
60
+ *.sql
61
+ *.sqlite
62
+
63
+ # OS generated files #
64
+ ######################
65
+ .DS_Store
66
+ .DS_Store?
67
+ ._*
68
+ .Spotlight-V100
69
+ .Trashes
70
+ Icon?
71
+ ehthumbs.db
72
+ Thumbs.db
3
73
  /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
74
+ /coverage
75
+ /.editorconfig
data/.travis.yml ADDED
@@ -0,0 +1,29 @@
1
+ language: ruby
2
+
3
+ sudo: false
4
+
5
+ cache: bundler
6
+
7
+ before_script:
8
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
+ - chmod +x ./cc-test-reporter
10
+ - ./cc-test-reporter before-build
11
+
12
+ script:
13
+ - bundle exec rspec
14
+
15
+ after_script:
16
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
17
+
18
+ addons:
19
+ postgresql: "9.3"
20
+
21
+ rvm:
22
+ - 2.5
23
+ - 2.4
24
+ - 2.3
25
+
26
+ gemfile:
27
+ - gemfiles/activerecord-5.1.Gemfile
28
+ - gemfiles/activerecord-5.0.Gemfile
29
+ - gemfiles/activerecord-4.2.Gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # QuickCount
2
+
3
+ ## 0.0.6 _(March 17th 2018)_
4
+ - Improved accuracy of `quick_count` by an average of 2.16%
5
+ - Configurable threshold
6
+ - Configurable schema
7
+
8
+ ## 0.0.5 _(November 29th 2017)_
9
+ - Tests (no signficant changes)
10
+
11
+ ## 0.0.4 _(April 11th 2017)_
12
+ - Fix root method privacy
13
+
14
+ ## 0.0.3 _(April 9th 2017)_
15
+ - No significant changes
16
+
17
+ ## 0.0.2 _(April 9th 2017)_
18
+ - Adding `count_estimate` helper
19
+
20
+ ## 0.0.1 _(April 8th 2017)_
21
+ - Initial functionality
data/Gemfile CHANGED
@@ -1,16 +1,19 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Declare your gem's dependencies in quick_count.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
6
3
  gemspec
7
4
 
8
- # Declare any dependencies that are still in development here instead of in
9
- # your gemspec. These might include edge Rails or gems from your path or
10
- # Git. Remember to move these dependencies to your gemspec before releasing
11
- # your gem to rubygems.org.
12
- group :development, :test do
13
- gem 'pg', platform: :mri
14
- gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
15
- end
5
+ group :test do
6
+
7
+ # Generates coverage stats of specs
8
+ gem 'simplecov'
9
+
10
+ # Publishes coverage to codeclimate
11
+ gem 'codeclimate-test-reporter'
12
+
13
+ gem 'rspec'
16
14
 
15
+ gem 'database_cleaner'
16
+
17
+ gem 'combustion'
18
+
19
+ end
data/README.md CHANGED
@@ -1,9 +1,32 @@
1
+ [![Version ](https://img.shields.io/gem/v/quick_count.svg?maxAge=2592000)](https://rubygems.org/gems/quick_count)
2
+ [![Build Status ](https://travis-ci.org/TwilightCoders/quick_count.svg)](https://travis-ci.org/TwilightCoders/quick_count)
3
+ [![Code Climate ](https://api.codeclimate.com/v1/badges/43ba3e038a91b44fba2c/maintainability)](https://codeclimate.com/github/TwilightCoders/quick_count/maintainability)
4
+ [![Test Coverage](https://codeclimate.com/github/TwilightCoders/quick_count/badges/coverage.svg)](https://codeclimate.com/github/TwilightCoders/quick_count/coverage)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/TwilightCoders/quick_count.svg)](https://gemnasium.com/github.com/TwilightCoders/quick_count)
6
+
1
7
  # QuickCount
2
8
 
3
- Based on the answer http://stackoverflow.com/a/7945274/1454158.
9
+ Unfortunately, it's currently notoriously difficult and expensive to get an exact count on large tables.
10
+
11
+ Luckily, there are [some tricks](https://www.citusdata.com/blog/2016/10/12/count-performance) for quickly getting fairly accurate estimates. For example, on a table with over 450 million records, you can get a 99.82% accurate count within a fraction of of the time. See the table below for an example dataset.
12
+
13
+ **Supports:**
14
+ - PostgreSQL
15
+ - [Multi-table Inheritance](https://github.com/TwilightCoders/active_record-mti)
4
16
 
5
- It currently supports only Postgres.
17
+ | SQL | Version | Result | Accuracy | Time |
18
+ | --- | --- | --- | --- | --- |
19
+ | `SELECT count(*) FROM small_table;` | -- | `2037104` | `100.0000000%` | `4.900s` |
20
+ | `SELECT quick_count('small_table');` | `v0.0.5` | `1988857` | `97.63158877%` | `0.048s` |
21
+ | `SELECT quick_count('small_table');` | `v0.0.6` | `2036407` | `99.96578476%` | `0.050s` |
22
+ | `SELECT count(*) FROM medium_table;` | -- | `81716243` | `100.0000000%` | `257.5s` |
23
+ | `SELECT quick_count('medium_table');` | `v0.0.5` | `79352284` | `97.10711247%` | `0.049s` |
24
+ | `SELECT quick_count('medium_table');` | `v0.0.6` | `81600513` | `99.85837577%` | `0.048s` |
25
+ | `SELECT count(*) FROM large_table;` | -- | `455270802` | `100.0000000%` | `310.6s` |
26
+ | `SELECT quick_count('large_table');` | `v0.0.5` | `448170751` | `98.44047741%` | `0.047s` |
27
+ | `SELECT quick_count('large_table');` | `v0.0.6` | `454448393` | `99.81935828%` | `0.046s` |
6
28
 
29
+ _These metrics were pulled from real databases being used in a production environment._
7
30
 
8
31
  ## Installation
9
32
 
@@ -17,10 +40,6 @@ And then execute:
17
40
 
18
41
  $ bundle
19
42
 
20
- And in a rails console:
21
-
22
- $ QuickCount.install
23
-
24
43
  Or install it yourself as:
25
44
 
26
45
  $ gem install quick_count
@@ -30,13 +49,21 @@ Or install it yourself as:
30
49
  ```ruby
31
50
  # user.rb
32
51
 
52
+ QuickCount.install # Install with default (500000) threshold
53
+
54
+ # Change the threshold for when `quick_count` kicks in...
55
+ QuickCount.install(threshold: 500000)
56
+
33
57
  class User < ActiveRecord::Base
34
58
 
35
59
  end
36
60
 
37
61
  User.quick_count
38
- ```
39
62
 
63
+ # Override the default threshold on a case-by-case basis.
64
+ User.quick_count(threshold: 600000)
65
+
66
+ ```
40
67
 
41
68
  ## Uninstallation
42
69
 
@@ -65,7 +92,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
65
92
 
66
93
  ## Contributing
67
94
 
68
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/quick_count.
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/TwilightCoders/quick_count.
69
96
 
70
97
 
71
98
  ## License
@@ -0,0 +1,3 @@
1
+ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
+
3
+ gem 'activerecord', '~> 4.0.0'
@@ -0,0 +1,3 @@
1
+ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
+
3
+ gem 'activerecord', '~> 4.1.0'
@@ -0,0 +1,3 @@
1
+ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
+
3
+ gem 'activerecord', '~> 4.2.0'
@@ -0,0 +1,3 @@
1
+ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
+
3
+ gem 'activerecord', '~> 5.0.0'
@@ -0,0 +1,3 @@
1
+ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
+
3
+ gem 'activerecord', '~> 5.1.0'
data/lib/quick_count.rb CHANGED
@@ -1,11 +1,9 @@
1
+ require 'quick_count/version'
1
2
  require 'quick_count/railtie'
2
3
  require 'active_record'
3
- require 'rake'
4
4
 
5
5
  module QuickCount
6
6
 
7
- public
8
-
9
7
  def self.root
10
8
  @root ||= Pathname.new(File.dirname(File.expand_path(File.dirname(__FILE__), '/../')))
11
9
  end
@@ -15,31 +13,50 @@ module QuickCount
15
13
  ::ActiveRecord::Relation.send :include, CountEstimate::ActiveRecord::Relation
16
14
  end
17
15
 
18
- def self.install
19
- ::ActiveRecord::Base.connection.execute(<<-eos
20
- CREATE OR REPLACE FUNCTION quick_count(table_name text) RETURNS bigint AS
16
+ def self.install(threshold: 500000, schema: 'public')
17
+ ::ActiveRecord::Base.connection.execute(quick_count_sql(schema: schema, threshold: threshold))
18
+ ::ActiveRecord::Base.connection.execute(count_estimate_sql(schema: schema))
19
+ end
20
+
21
+ def self.uninstall(schema: 'public')
22
+ ::ActiveRecord::Base.connection.execute("DROP FUNCTION IF EXISTS #{schema}.quick_count(text, bigint);")
23
+ ::ActiveRecord::Base.connection.execute("DROP FUNCTION IF EXISTS #{schema}.quick_count(text);")
24
+ ::ActiveRecord::Base.connection.execute("DROP FUNCTION IF EXISTS #{schema}.count_estimate(text);")
25
+ end
26
+
27
+ private
28
+
29
+ def self.quick_count_sql(threshold: 500000, schema: 'public')
30
+ <<-SQL
31
+ CREATE OR REPLACE FUNCTION #{schema}.quick_count(table_name text, threshold bigint default #{threshold}) RETURNS bigint AS
21
32
  $func$
22
- DECLARE
23
- rec record;
24
- rows integer;
33
+ DECLARE count bigint;
25
34
  BEGIN
26
- RETURN (SELECT SUM(estimate) AS estimate FROM (
27
- SELECT
28
- SUM(child.reltuples::bigint) AS estimate
29
- FROM pg_inherits
30
- JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
31
- JOIN pg_class child ON pg_inherits.inhrelid = child.oid
32
- JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
33
- JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
34
- WHERE parent.relname = table_name
35
- GROUP BY parent.reltuples
36
- UNION SELECT reltuples::bigint AS estimate FROM pg_class where relname=table_name) as tables);
35
+ EXECUTE 'SELECT
36
+ CASE
37
+ WHEN SUM(estimate)::integer < '|| threshold ||' THEN
38
+ (SELECT COUNT(*) FROM '|| table_name ||')
39
+ ELSE
40
+ SUM(estimate)::integer
41
+ END AS count
42
+ FROM (
43
+ SELECT
44
+ ((SUM(child.reltuples::float)/greatest(SUM(child.relpages::float),1))) * (SUM(pg_relation_size(child.oid))::float / (current_setting(''block_size'')::float)) AS estimate
45
+ FROM pg_inherits
46
+ JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
47
+ JOIN pg_class child ON pg_inherits.inhrelid = child.oid
48
+ WHERE parent.relname = '''|| table_name ||'''
49
+ UNION SELECT (reltuples::float/greatest(relpages::float, 1)) * (pg_relation_size(pg_class.oid)::float / (current_setting(''block_size'')::float)) AS estimate FROM pg_class where relname='''|| table_name ||'''
50
+ ) AS tables' INTO count;
51
+ RETURN count;
37
52
  END
38
53
  $func$ LANGUAGE plpgsql;
39
- eos
40
- )
41
- ::ActiveRecord::Base.connection.execute(<<-eos
42
- CREATE OR REPLACE FUNCTION count_estimate(query text) RETURNS integer AS
54
+ SQL
55
+ end
56
+
57
+ def self.count_estimate_sql(schema: 'public')
58
+ <<-SQL
59
+ CREATE OR REPLACE FUNCTION #{schema}.count_estimate(query text) RETURNS integer AS
43
60
  $func$
44
61
  DECLARE
45
62
  rec record;
@@ -53,13 +70,7 @@ module QuickCount
53
70
  RETURN rows;
54
71
  END
55
72
  $func$ LANGUAGE plpgsql;
56
- eos
57
- )
58
- end
59
-
60
- def self.uninstall
61
- ::ActiveRecord::Base.connection.execute("DROP FUNCTION quick_count(text);")
62
- ::ActiveRecord::Base.connection.execute("DROP FUNCTION count_estimate(text);")
73
+ SQL
63
74
  end
64
75
 
65
76
  end
@@ -7,8 +7,9 @@ module QuickCount
7
7
 
8
8
  module ClassMethods
9
9
 
10
- def quick_count
11
- result = ::ActiveRecord::Base.connection.execute("SELECT quick_count('#{table_name}')")
10
+ def quick_count(threshold: nil)
11
+ threshold = threshold ? ", #{threshold}" : nil
12
+ result = ::ActiveRecord::Base.connection.execute("SELECT quick_count('#{table_name}'#{threshold})")
12
13
  result[0]["quick_count"].to_i
13
14
  end
14
15
 
@@ -1,3 +1,3 @@
1
1
  module QuickCount
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/quick_count.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['dale@twilightcoders.net']
11
11
 
12
12
  spec.summary = 'Quickly get an accurate count estimation for large tables.'
13
+ spec.description = 'Installs two database functions, `quick_count` and `count_estimate` for getting count estimations on large tables'
13
14
  spec.homepage = "https://github.com/TwilightCoders/quick_count"
14
15
  spec.license = 'MIT'
15
16
 
@@ -21,23 +22,22 @@ Gem::Specification.new do |spec|
21
22
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
22
23
  end
23
24
 
24
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- spec.bindir = 'exe'
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.test_files = spec.files.grep(%r{^spec/})
28
- spec.require_paths = ['lib']
25
+ spec.files = `git ls-files -z`.split("\x0")
26
+ spec.bindir = 'bin'
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
29
+ spec.require_paths = ['lib', 'spec']
29
30
 
30
- spec.required_ruby_version = '~> 2.1'
31
+ rails_versions = ['>= 4', '< 6']
32
+ spec.required_ruby_version = '>= 2.0'
31
33
 
32
- rails_versions = ['>= 4.1', '< 6']
33
-
34
- spec.add_runtime_dependency 'pg', ['>= 0.12.0', '< 0.30.0']
34
+ spec.add_runtime_dependency 'pg', '~> 0'
35
35
  spec.add_runtime_dependency 'activerecord', rails_versions
36
- spec.add_runtime_dependency 'activesupport', rails_versions
37
- spec.add_runtime_dependency 'activemodel', rails_versions
38
36
  spec.add_runtime_dependency 'railties', rails_versions
39
37
 
40
- spec.add_development_dependency 'bundler', '~> 1.5'
41
- spec.add_development_dependency 'rspec', '~> 3.3'
42
- spec.add_development_dependency 'pry', '~> 0'
38
+ spec.add_development_dependency 'pry-byebug', '~> 3'
39
+ spec.add_development_dependency 'bundler', '~> 1.3'
40
+ spec.add_development_dependency 'rake', '~> 12.0'
41
+ spec.add_development_dependency 'combustion', '~> 0.7'
42
+
43
43
  end
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+
3
+ describe QuickCount do
4
+ it "is present in models" do
5
+ expect(Post).to respond_to(:quick_count)
6
+ expect(Post.all).to respond_to(:count_estimate)
7
+ end
8
+
9
+ it "returns the correct count" do
10
+ expect(Post.quick_count).to be(0)
11
+ expect(Post.all.count_estimate).to be > 0
12
+ end
13
+
14
+ it "root has the right value" do
15
+ expect(QuickCount.root).not_to be_nil
16
+ end
17
+
18
+ end
@@ -0,0 +1,29 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'database_cleaner'
4
+ require 'combustion'
5
+
6
+ require 'simplecov'
7
+ SimpleCov.start do
8
+ add_filter 'spec'
9
+ end
10
+
11
+ Combustion.path = 'spec/support/rails'
12
+ Combustion.initialize! :active_record
13
+
14
+ schema = "quick_count"
15
+
16
+ RSpec.configure do |config|
17
+ config.order = "random"
18
+
19
+ config.before(:suite) do
20
+ ActiveRecord::Base.connection.execute("CREATE SCHEMA #{schema}")
21
+ QuickCount.install(schema: schema)
22
+ end
23
+
24
+ config.after(:suite) do
25
+ QuickCount.uninstall(schema: schema)
26
+ ActiveRecord::Base.connection.execute("DROP SCHEMA #{schema}")
27
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ class Post < ::ActiveRecord::Base
2
+ belongs_to :user
3
+ end
@@ -0,0 +1,3 @@
1
+ class User < ::ActiveRecord::Base
2
+ has_many :posts
3
+ end
@@ -0,0 +1,5 @@
1
+ test:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: quick_count-test
5
+ schema_search_path: "quick_count,public"
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,14 @@
1
+ ActiveRecord::Schema.define do
2
+ self.verbose = false
3
+
4
+ create_table :users do |t|
5
+ t.string :name
6
+ end
7
+
8
+ create_table :posts do |t|
9
+ t.integer :user_id
10
+ t.string :title
11
+ t.timestamps
12
+ end
13
+
14
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
metadata CHANGED
@@ -1,62 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_count
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Stevens
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2018-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.12.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 0.30.0
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.12.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 0.30.0
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activerecord
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: '4.1'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '6'
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '4.1'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '6'
53
- - !ruby/object:Gem::Dependency
54
- name: activesupport
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '4.1'
33
+ version: '4'
60
34
  - - "<"
61
35
  - !ruby/object:Gem::Version
62
36
  version: '6'
@@ -66,17 +40,17 @@ dependencies:
66
40
  requirements:
67
41
  - - ">="
68
42
  - !ruby/object:Gem::Version
69
- version: '4.1'
43
+ version: '4'
70
44
  - - "<"
71
45
  - !ruby/object:Gem::Version
72
46
  version: '6'
73
47
  - !ruby/object:Gem::Dependency
74
- name: activemodel
48
+ name: railties
75
49
  requirement: !ruby/object:Gem::Requirement
76
50
  requirements:
77
51
  - - ">="
78
52
  - !ruby/object:Gem::Version
79
- version: '4.1'
53
+ version: '4'
80
54
  - - "<"
81
55
  - !ruby/object:Gem::Version
82
56
  version: '6'
@@ -86,73 +60,68 @@ dependencies:
86
60
  requirements:
87
61
  - - ">="
88
62
  - !ruby/object:Gem::Version
89
- version: '4.1'
63
+ version: '4'
90
64
  - - "<"
91
65
  - !ruby/object:Gem::Version
92
66
  version: '6'
93
67
  - !ruby/object:Gem::Dependency
94
- name: railties
68
+ name: pry-byebug
95
69
  requirement: !ruby/object:Gem::Requirement
96
70
  requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '4.1'
100
- - - "<"
71
+ - - "~>"
101
72
  - !ruby/object:Gem::Version
102
- version: '6'
103
- type: :runtime
73
+ version: '3'
74
+ type: :development
104
75
  prerelease: false
105
76
  version_requirements: !ruby/object:Gem::Requirement
106
77
  requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '4.1'
110
- - - "<"
78
+ - - "~>"
111
79
  - !ruby/object:Gem::Version
112
- version: '6'
80
+ version: '3'
113
81
  - !ruby/object:Gem::Dependency
114
82
  name: bundler
115
83
  requirement: !ruby/object:Gem::Requirement
116
84
  requirements:
117
85
  - - "~>"
118
86
  - !ruby/object:Gem::Version
119
- version: '1.5'
87
+ version: '1.3'
120
88
  type: :development
121
89
  prerelease: false
122
90
  version_requirements: !ruby/object:Gem::Requirement
123
91
  requirements:
124
92
  - - "~>"
125
93
  - !ruby/object:Gem::Version
126
- version: '1.5'
94
+ version: '1.3'
127
95
  - !ruby/object:Gem::Dependency
128
- name: rspec
96
+ name: rake
129
97
  requirement: !ruby/object:Gem::Requirement
130
98
  requirements:
131
99
  - - "~>"
132
100
  - !ruby/object:Gem::Version
133
- version: '3.3'
101
+ version: '12.0'
134
102
  type: :development
135
103
  prerelease: false
136
104
  version_requirements: !ruby/object:Gem::Requirement
137
105
  requirements:
138
106
  - - "~>"
139
107
  - !ruby/object:Gem::Version
140
- version: '3.3'
108
+ version: '12.0'
141
109
  - !ruby/object:Gem::Dependency
142
- name: pry
110
+ name: combustion
143
111
  requirement: !ruby/object:Gem::Requirement
144
112
  requirements:
145
113
  - - "~>"
146
114
  - !ruby/object:Gem::Version
147
- version: '0'
115
+ version: '0.7'
148
116
  type: :development
149
117
  prerelease: false
150
118
  version_requirements: !ruby/object:Gem::Requirement
151
119
  requirements:
152
120
  - - "~>"
153
121
  - !ruby/object:Gem::Version
154
- version: '0'
155
- description:
122
+ version: '0.7'
123
+ description: Installs two database functions, `quick_count` and `count_estimate` for
124
+ getting count estimations on large tables
156
125
  email:
157
126
  - dale@twilightcoders.net
158
127
  executables: []
@@ -160,17 +129,32 @@ extensions: []
160
129
  extra_rdoc_files: []
161
130
  files:
162
131
  - ".gitignore"
132
+ - ".travis.yml"
133
+ - CHANGELOG.md
163
134
  - Gemfile
164
- - Gemfile.lock
165
135
  - MIT-LICENSE
166
136
  - README.md
167
137
  - Rakefile
138
+ - gemfiles/activerecord-4.0.Gemfile
139
+ - gemfiles/activerecord-4.1.Gemfile
140
+ - gemfiles/activerecord-4.2.Gemfile
141
+ - gemfiles/activerecord-5.0.Gemfile
142
+ - gemfiles/activerecord-5.1.Gemfile
168
143
  - lib/count_estimate/active_record/relation.rb
169
144
  - lib/quick_count.rb
170
145
  - lib/quick_count/active_record/base.rb
171
146
  - lib/quick_count/railtie.rb
172
147
  - lib/quick_count/version.rb
173
148
  - quick_count.gemspec
149
+ - spec/quick_count_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/support/rails/app/models/post.rb
152
+ - spec/support/rails/app/models/user.rb
153
+ - spec/support/rails/config/database.yml
154
+ - spec/support/rails/config/routes.rb
155
+ - spec/support/rails/db/schema.rb
156
+ - spec/support/rails/log/.gitignore
157
+ - spec/support/rails/public/favicon.ico
174
158
  homepage: https://github.com/TwilightCoders/quick_count
175
159
  licenses:
176
160
  - MIT
@@ -180,11 +164,12 @@ post_install_message:
180
164
  rdoc_options: []
181
165
  require_paths:
182
166
  - lib
167
+ - spec
183
168
  required_ruby_version: !ruby/object:Gem::Requirement
184
169
  requirements:
185
- - - "~>"
170
+ - - ">="
186
171
  - !ruby/object:Gem::Version
187
- version: '2.1'
172
+ version: '2.0'
188
173
  required_rubygems_version: !ruby/object:Gem::Requirement
189
174
  requirements:
190
175
  - - ">="
@@ -192,8 +177,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
177
  version: '0'
193
178
  requirements: []
194
179
  rubyforge_project:
195
- rubygems_version: 2.6.11
180
+ rubygems_version: 2.7.5
196
181
  signing_key:
197
182
  specification_version: 4
198
183
  summary: Quickly get an accurate count estimation for large tables.
199
- test_files: []
184
+ test_files:
185
+ - spec/quick_count_spec.rb
186
+ - spec/spec_helper.rb
187
+ - spec/support/rails/app/models/post.rb
188
+ - spec/support/rails/app/models/user.rb
189
+ - spec/support/rails/config/database.yml
190
+ - spec/support/rails/config/routes.rb
191
+ - spec/support/rails/db/schema.rb
192
+ - spec/support/rails/log/.gitignore
193
+ - spec/support/rails/public/favicon.ico
data/Gemfile.lock DELETED
@@ -1,103 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- quick_count (0.0.1)
5
- activemodel (>= 4.1, < 6)
6
- activerecord (>= 4.1, < 6)
7
- activesupport (>= 4.1, < 6)
8
- pg (>= 0.12.0, < 0.30.0)
9
- railties (>= 4.1, < 6)
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- actionpack (5.0.2)
15
- actionview (= 5.0.2)
16
- activesupport (= 5.0.2)
17
- rack (~> 2.0)
18
- rack-test (~> 0.6.3)
19
- rails-dom-testing (~> 2.0)
20
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
- actionview (5.0.2)
22
- activesupport (= 5.0.2)
23
- builder (~> 3.1)
24
- erubis (~> 2.7.0)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
- activemodel (5.0.2)
28
- activesupport (= 5.0.2)
29
- activerecord (5.0.2)
30
- activemodel (= 5.0.2)
31
- activesupport (= 5.0.2)
32
- arel (~> 7.0)
33
- activesupport (5.0.2)
34
- concurrent-ruby (~> 1.0, >= 1.0.2)
35
- i18n (~> 0.7)
36
- minitest (~> 5.1)
37
- tzinfo (~> 1.1)
38
- arel (7.1.4)
39
- builder (3.2.3)
40
- coderay (1.1.1)
41
- concurrent-ruby (1.0.5)
42
- diff-lcs (1.3)
43
- erubis (2.7.0)
44
- i18n (0.8.1)
45
- loofah (2.0.3)
46
- nokogiri (>= 1.5.9)
47
- method_source (0.8.2)
48
- mini_portile2 (2.1.0)
49
- minitest (5.10.1)
50
- nokogiri (1.7.1)
51
- mini_portile2 (~> 2.1.0)
52
- pg (0.20.0)
53
- pry (0.10.4)
54
- coderay (~> 1.1.0)
55
- method_source (~> 0.8.1)
56
- slop (~> 3.4)
57
- rack (2.0.1)
58
- rack-test (0.6.3)
59
- rack (>= 1.0)
60
- rails-dom-testing (2.0.2)
61
- activesupport (>= 4.2.0, < 6.0)
62
- nokogiri (~> 1.6)
63
- rails-html-sanitizer (1.0.3)
64
- loofah (~> 2.0)
65
- railties (5.0.2)
66
- actionpack (= 5.0.2)
67
- activesupport (= 5.0.2)
68
- method_source
69
- rake (>= 0.8.7)
70
- thor (>= 0.18.1, < 2.0)
71
- rake (12.0.0)
72
- rspec (3.5.0)
73
- rspec-core (~> 3.5.0)
74
- rspec-expectations (~> 3.5.0)
75
- rspec-mocks (~> 3.5.0)
76
- rspec-core (3.5.4)
77
- rspec-support (~> 3.5.0)
78
- rspec-expectations (3.5.0)
79
- diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.5.0)
81
- rspec-mocks (3.5.0)
82
- diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.5.0)
84
- rspec-support (3.5.0)
85
- slop (3.6.0)
86
- thor (0.19.4)
87
- thread_safe (0.3.6)
88
- tzinfo (1.2.3)
89
- thread_safe (~> 0.1)
90
-
91
- PLATFORMS
92
- ruby
93
-
94
- DEPENDENCIES
95
- activerecord-jdbcpostgresql-adapter
96
- bundler (~> 1.5)
97
- pg
98
- pry (~> 0)
99
- quick_count!
100
- rspec (~> 3.3)
101
-
102
- BUNDLED WITH
103
- 1.13.6