fast_page 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c34b1767bb6dbece4339563801e4212941e680f6126addeadb4b454a77373c9c
4
- data.tar.gz: 2c30353c390161c8b37d12bddc30ef0f1f29fabcb0fe77ab950ca67fa6eee33c
3
+ metadata.gz: 5cbe26206c49286c01fcab014490db153e8f365e3b8e4338e5bfba6bf6085883
4
+ data.tar.gz: 89d213a8260026721de817d56f9692d5691ccd250aeee229dad86d9fe2f6a7e5
5
5
  SHA512:
6
- metadata.gz: f8edd90c67bf113d202ceb88f6815fd25184a55cb6917a618143acc5f18aabcbfe60288051eada0ea2ca646b2f910d4f4d8e367d9f191ad8f253c20809bcdfdf
7
- data.tar.gz: 179b2f74676f2c76624f54fdb35697956dae55b14668f0b49154840da60604dedc74da0b16e5555d5e85aa3e184a75044ee5fa7071597ac32d43ba7bc248639b
6
+ metadata.gz: 47a1122b7eddcc8e1eb4961c5abb5f56926b39255ee3be5321a8a56541a2bdfd7b1de4bb4e714469412238d1c8253d3e891444408694c402dbc86718048a202d
7
+ data.tar.gz: 1242c919d036ccc33de101a41358fa7de1150e5a253deead5d538cb6bdce164554fbc4de8cf8d749693de9940dfbf1d725d111f9498b7037eee388c612129d71
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_page (0.1.2)
4
+ fast_page (0.1.3)
5
5
  activerecord
6
6
  activesupport
7
7
 
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  **`FastPage` applies the MySQL "deferred join" optimization to your ActiveRecord offset/limit queries.⚡️**
4
4
 
5
+ [![See on RubyGems](https://badge.fury.io/rb/fast_page.svg)](https://badge.fury.io/rb/fast_page)
6
+
5
7
  ## Usage
6
8
 
7
9
  Add `fast_page` to your Gemfile.
@@ -6,10 +6,20 @@ module FastPage
6
6
  # Must have a limit or offset defined
7
7
  raise ArgumentError, "You must specify a limit or offset to use fast_page" if !limit_value && !offset_value
8
8
 
9
+ # We load 1 additional record to determine if there is a next page.
10
+ # This helps us avoid doing a count over all records
11
+ @values[:limit] = limit_value + 1 if limit_value
9
12
  id_scope = dup
10
13
  id_scope = id_scope.except(:includes) unless references_eager_loaded_tables?
11
14
  ids = id_scope.pluck(:id)
12
15
 
16
+ if limit_value
17
+ @values[:limit] = limit_value - 1
18
+ # Record if there is a next page
19
+ @_has_next = ids.length > limit_value
20
+ ids = ids.first(limit_value)
21
+ end
22
+
13
23
  if ids.empty?
14
24
  @records = []
15
25
  @loaded = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastPage
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Coutermarsh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord