dont_you_count 0.0.1 → 0.0.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: 889ba09eab573a511b26f3d9b846d93fbf5024c1
4
- data.tar.gz: e9d9edae9e3fa8c7d7e5d7c61869a6a1c3242165
3
+ metadata.gz: b042c375c3d5fff57597f5cafada1d70b94a6db1
4
+ data.tar.gz: 395aa04c54b7a55eafee41779f028556a4ed10a3
5
5
  SHA512:
6
- metadata.gz: 968c5fc97904243f94ea458c4a44edf9d2769bec3ecff6c10fa2429c63429f3b5ebd73710e3db79b8b59fea4e43ea5c6238561d8eefca7914ed49b1c17452c21
7
- data.tar.gz: 9cc3dd0d4ba3aacfda25efb2e355509ec8d7ce0799f883ca1228660c28204dcef489cbc151b5ff6955d89ccf2e4cbc6648f5d77b4b5cc1b3f1dfab9d255750af
6
+ metadata.gz: 02818f69dd927f0581b19a728a4659df045da9e00365073fc02065bd23f2f46a40064ce5d8b90560a274723d427e5a12c260351e7f5b56f00e888b98ac2ef248
7
+ data.tar.gz: 9e781abe5a1e84486b7ba24c33a4ad0b67c13decf1811cd641e8d6a8f92df93b87628648ef8a7ef336075567beb92d29a36600df98deef64f658315141d5f136
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -1,2 +1,35 @@
1
- # ActiveAdmin - Don't you count
1
+ # Don't you count
2
2
 
3
+ [ActiveAdmin](https://github.com/activeadmin/activeadmin) is a great way to boostrap a good looking and customizable admin interface in no time. However there are some pererformance issues related to using this tool.
4
+
5
+ ## What is it about?
6
+
7
+ When displaying the index view AA automatically issues a `SELECT COUNT(*)` SQL query in order to enable pagination. As long as you have no more than couple thousand records in your db it is instant. However once your collections start getting bigger this single query could timeout your server. And this is no good. Setting:
8
+ ````ruby
9
+ index pagination_total: false do ...
10
+ ```
11
+ does not prevent the `count` query.
12
+
13
+ ## How to use ?
14
+
15
+ Gemfile
16
+
17
+ ``` ruby
18
+ gem 'dont_you_count' # below activeadmin gem
19
+ ```
20
+
21
+ config/initializers/active_admin.rb
22
+
23
+ ````ruby
24
+ ActiveAdmin.setup do |config|
25
+ config.dont_count = ['product', 'order']
26
+ end
27
+ ````
28
+
29
+ That's it. The `count` query will no longer be issued for `product` and `offer` models. The total count will be guessed instead (based on [this gist](https://gist.github.com/sononum/6183139)). It breaks the last pagination button but it is better then breaking the servers.
30
+
31
+ ## Compatibility
32
+
33
+ Tested to work with activeadmin (1.0.0.pre) and kaminari (0.16.1). Let me know if you notice any problems with other versions.
34
+
35
+ Pull requests are welcome.
@@ -3,7 +3,7 @@ module Kaminari
3
3
  module PageScopeMethods
4
4
  def total_count(column_name = :all, options = {})
5
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)
6
+ 2000000
7
7
  else
8
8
  @total_count ||= begin
9
9
  c = except(:offset, :limit, :order)
@@ -1,3 +1,3 @@
1
1
  module DontYouCount
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dont_you_count
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-28 00:00:00.000000000 Z
11
+ date: 2015-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -45,11 +45,13 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".gitignore"
48
49
  - Gemfile
49
50
  - Gemfile.lock
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
54
+ - dont_you_count-0.0.1.gem
53
55
  - dont_you_count.gemspec
54
56
  - lib/dont_you_count.rb
55
57
  - lib/dont_you_count/active_admin.rb