dont_you_count 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 889ba09eab573a511b26f3d9b846d93fbf5024c1
4
+ data.tar.gz: e9d9edae9e3fa8c7d7e5d7c61869a6a1c3242165
5
+ SHA512:
6
+ metadata.gz: 968c5fc97904243f94ea458c4a44edf9d2769bec3ecff6c10fa2429c63429f3b5ebd73710e3db79b8b59fea4e43ea5c6238561d8eefca7914ed49b1c17452c21
7
+ data.tar.gz: 9cc3dd0d4ba3aacfda25efb2e355509ec8d7ce0799f883ca1228660c28204dcef489cbc151b5ff6955d89ccf2e4cbc6648f5d77b4b5cc1b3f1dfab9d255750af
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,146 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.21)
10
+ actionpack (= 3.2.21)
11
+ mail (~> 2.5.4)
12
+ actionpack (3.2.21)
13
+ activemodel (= 3.2.21)
14
+ activesupport (= 3.2.21)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.5)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activeadmin (0.6.6)
23
+ arbre (~> 1.0)
24
+ bourbon (>= 1.0.0, < 4)
25
+ devise (>= 1.5.4, < 4)
26
+ formtastic (~> 2.0)
27
+ inherited_resources (~> 1.3)
28
+ jquery-rails (>= 1.0.0, < 3)
29
+ kaminari (~> 0.13, != 0.15.0)
30
+ meta_search (~> 1.0)
31
+ rails (>= 3.0.0, < 4)
32
+ sass (~> 3.1)
33
+ activemodel (3.2.21)
34
+ activesupport (= 3.2.21)
35
+ builder (~> 3.0.0)
36
+ activerecord (3.2.21)
37
+ activemodel (= 3.2.21)
38
+ activesupport (= 3.2.21)
39
+ arel (~> 3.0.2)
40
+ tzinfo (~> 0.3.29)
41
+ activeresource (3.2.21)
42
+ activemodel (= 3.2.21)
43
+ activesupport (= 3.2.21)
44
+ activesupport (3.2.21)
45
+ i18n (~> 0.6, >= 0.6.4)
46
+ multi_json (~> 1.0)
47
+ arbre (1.0.3)
48
+ activesupport (>= 3.0.0)
49
+ arel (3.0.3)
50
+ bcrypt (3.1.10)
51
+ bourbon (3.2.4)
52
+ sass (~> 3.2)
53
+ thor
54
+ builder (3.0.4)
55
+ devise (3.4.1)
56
+ bcrypt (~> 3.0)
57
+ orm_adapter (~> 0.1)
58
+ railties (>= 3.2.6, < 5)
59
+ responders
60
+ thread_safe (~> 0.1)
61
+ warden (~> 1.2.3)
62
+ erubis (2.7.0)
63
+ formtastic (2.3.1)
64
+ actionpack (>= 3.0)
65
+ has_scope (0.6.0)
66
+ actionpack (>= 3.2, < 5)
67
+ activesupport (>= 3.2, < 5)
68
+ hike (1.2.3)
69
+ i18n (0.7.0)
70
+ inherited_resources (1.6.0)
71
+ actionpack (>= 3.2, < 5)
72
+ has_scope (~> 0.6.0.rc)
73
+ railties (>= 3.2, < 5)
74
+ responders
75
+ journey (1.0.4)
76
+ jquery-rails (2.3.0)
77
+ railties (>= 3.0, < 5.0)
78
+ thor (>= 0.14, < 2.0)
79
+ json (1.8.2)
80
+ kaminari (0.16.3)
81
+ actionpack (>= 3.0.0)
82
+ activesupport (>= 3.0.0)
83
+ mail (2.5.4)
84
+ mime-types (~> 1.16)
85
+ treetop (~> 1.4.8)
86
+ meta_search (1.1.3)
87
+ actionpack (~> 3.1)
88
+ activerecord (~> 3.1)
89
+ activesupport (~> 3.1)
90
+ polyamorous (~> 0.5.0)
91
+ mime-types (1.25.1)
92
+ multi_json (1.10.1)
93
+ orm_adapter (0.5.0)
94
+ polyamorous (0.5.0)
95
+ activerecord (~> 3.0)
96
+ polyglot (0.3.5)
97
+ rack (1.4.5)
98
+ rack-cache (1.2)
99
+ rack (>= 0.4)
100
+ rack-ssl (1.3.4)
101
+ rack
102
+ rack-test (0.6.3)
103
+ rack (>= 1.0)
104
+ rails (3.2.21)
105
+ actionmailer (= 3.2.21)
106
+ actionpack (= 3.2.21)
107
+ activerecord (= 3.2.21)
108
+ activeresource (= 3.2.21)
109
+ activesupport (= 3.2.21)
110
+ bundler (~> 1.0)
111
+ railties (= 3.2.21)
112
+ railties (3.2.21)
113
+ actionpack (= 3.2.21)
114
+ activesupport (= 3.2.21)
115
+ rack-ssl (~> 1.3.2)
116
+ rake (>= 0.8.7)
117
+ rdoc (~> 3.4)
118
+ thor (>= 0.14.6, < 2.0)
119
+ rake (10.4.2)
120
+ rdoc (3.12.2)
121
+ json (~> 1.4)
122
+ responders (1.1.2)
123
+ railties (>= 3.2, < 4.2)
124
+ sass (3.4.13)
125
+ sprockets (2.2.3)
126
+ hike (~> 1.2)
127
+ multi_json (~> 1.0)
128
+ rack (~> 1.0)
129
+ tilt (~> 1.1, != 1.3.0)
130
+ thor (0.19.1)
131
+ thread_safe (0.3.4)
132
+ tilt (1.4.1)
133
+ treetop (1.4.15)
134
+ polyglot
135
+ polyglot (>= 0.3.1)
136
+ tzinfo (0.3.43)
137
+ warden (1.2.3)
138
+ rack (>= 1.0)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ !
145
+ activeadmin
146
+ kaminari
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 pawurb
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # ActiveAdmin - Don't you count
2
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dont_you_count/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "dont_you_count"
8
+ gem.version = DontYouCount::VERSION
9
+ gem.authors = ["pawurb"]
10
+ gem.email = ["p.urbanek89@gmail.com"]
11
+ gem.summary = %q{Disable active admin count queries for selected tables}
12
+ gem.description = %q{Disable active admin count queries for selected tables}
13
+ gem.homepage = "http://github.com/pawurb/dont_you_count"
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.executables = []
16
+ gem.test_files = gem.files.grep(%r{^(spec)/})
17
+ gem.require_paths = ["lib"]
18
+ gem.license = "MIT"
19
+ gem.add_development_dependency "activeadmin"
20
+ gem.add_development_dependency "kaminari"
21
+ end
@@ -0,0 +1,6 @@
1
+ require 'dont_you_count/active_admin'
2
+ require 'dont_you_count/kaminari'
3
+ require 'dont_you_count/version'
4
+
5
+ module DontYouCount
6
+ end
@@ -0,0 +1,3 @@
1
+ ActiveAdmin::Application.class_eval do
2
+ inheritable_setting :dont_count, []
3
+ end
@@ -0,0 +1,29 @@
1
+ # Prevent long running select count queries for choosen tables, and preserve the oryginal behaviour for other tables
2
+ module Kaminari
3
+ module PageScopeMethods
4
+ def total_count(column_name = :all, options = {})
5
+ if ActiveAdmin.application.dont_count.include?(entry_name)
6
+ @_hacked_total_count || (@_hacked_total_count = self.connection.execute("SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname ='#{table_name}'").first["reltuples"].to_i)
7
+ else
8
+ @total_count ||= begin
9
+ c = except(:offset, :limit, :order)
10
+
11
+ # Remove includes only if they are irrelevant
12
+ c = c.except(:includes) unless references_eager_loaded_tables?
13
+
14
+ # Rails 4.1 removes the `options` argument from AR::Relation#count
15
+ args = [column_name]
16
+ args << options if ActiveRecord::VERSION::STRING < '4.1.0'
17
+
18
+ # .group returns an OrderdHash that responds to #count
19
+ c = c.count(*args)
20
+ if c.is_a?(Hash) || c.is_a?(ActiveSupport::OrderedHash)
21
+ c.count
22
+ else
23
+ c.respond_to?(:count) ? c.count(*args) : c
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module DontYouCount
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dont_you_count
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - pawurb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeadmin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kaminari
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Disable active admin count queries for selected tables
42
+ email:
43
+ - p.urbanek89@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - dont_you_count.gemspec
54
+ - lib/dont_you_count.rb
55
+ - lib/dont_you_count/active_admin.rb
56
+ - lib/dont_you_count/kaminari.rb
57
+ - lib/dont_you_count/version.rb
58
+ homepage: http://github.com/pawurb/dont_you_count
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Disable active admin count queries for selected tables
82
+ test_files: []