pagy_cursor 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: b30060ea35c9a871c94d64e1bca0a9d289e13a9c3751b34aca9b5d358df1e7bf
4
- data.tar.gz: cc89b1199ee954188859776d4db32b6634ad8efef34f7ffa94a917802a5fd701
3
+ metadata.gz: aeef340ec1e16f142493c13d33e9aff54b231be6e6bccbcd54407feafe8ee392
4
+ data.tar.gz: 6e4f963a7cc5ae9d19c6a07327464989081e69bfc6c431fa672aad91dded0af7
5
5
  SHA512:
6
- metadata.gz: 7450e19adcb2c85ff8cff5af659790ee7094a47580edc9e18ea6d5735da3c635357ca041908a2b160a1e19d3e45966c6e7f4757ea5d0881afa6d885d040f1cff
7
- data.tar.gz: bda797625d3c5579f6ae4f10f0a9a0623b41c11f82536047b3d95beabee13b8f0c16b2dc0fbf1daf390229f50c0e8e547cb2920ca7c47ca98f86e1fe69a776b8
6
+ metadata.gz: d78438ba52a1287c0c445d4e59a7688bf625116cd54468a6e879f2871361f9d3a2731c150ddb1c40f0c29c3dfdea387f0812cc2b20136ccdf4d511777565494b
7
+ data.tar.gz: 5f0498e40683a5e51caa923845e56fcf9d9633f6cb22b48c5fb9453bffbf5007f43ca7e5e24ae65de194c68fe1bfe3d6e90d70783a877ec69fb4b73c00734cc2
@@ -34,12 +34,14 @@ jobs:
34
34
  - ruby-version: 3.1
35
35
  env:
36
36
  BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
37
-
37
+ - ruby-version: 3.2
38
+ env:
39
+ BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
38
40
  fail-fast: false
39
41
  env: ${{ matrix.env }}
40
42
 
41
43
  steps:
42
- - uses: actions/checkout@v2
44
+ - uses: actions/checkout@v3
43
45
 
44
46
  - name: Set up ruby
45
47
  uses: ruby/setup-ruby@v1
@@ -74,16 +76,19 @@ jobs:
74
76
  - ruby-version: 2.7
75
77
  env:
76
78
  BUNDLE_GEMFILE: gemfiles/active_record_52.gemfile
77
- - ruby-version: 3.0
79
+ - ruby-version: "3.0"
78
80
  env:
79
81
  BUNDLE_GEMFILE: gemfiles/active_record_61.gemfile
80
82
  - ruby-version: 3.1
81
83
  env:
82
84
  BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
85
+ - ruby-version: 3.2
86
+ env:
87
+ BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
83
88
  fail-fast: false
84
89
  env: ${{ matrix.env }}
85
90
  steps:
86
- - uses: actions/checkout@v2
91
+ - uses: actions/checkout@v3
87
92
 
88
93
  - name: Set up ruby
89
94
  uses: ruby/setup-ruby@v1
@@ -11,10 +11,10 @@ jobs:
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
- - name: Set up Ruby 2.6
14
+ - name: Set up Ruby 3.1
15
15
  uses: actions/setup-ruby@v1
16
16
  with:
17
- version: 2.6.x
17
+ version: 3.1
18
18
 
19
19
  - name: Publish to RubyGems
20
20
  run: |
data/Gemfile.lock CHANGED
@@ -106,6 +106,8 @@ GEM
106
106
  net-smtp (0.3.3)
107
107
  net-protocol
108
108
  nio4r (2.5.9)
109
+ nokogiri (1.14.3-arm64-darwin)
110
+ racc (~> 1.4)
109
111
  nokogiri (1.14.3-x86_64-darwin)
110
112
  racc (~> 1.4)
111
113
  pagy (6.0.3)
@@ -157,6 +159,7 @@ GEM
157
159
  diff-lcs (>= 1.2.0, < 2.0)
158
160
  rspec-support (~> 3.12.0)
159
161
  rspec-support (3.12.0)
162
+ sqlite3 (1.6.2-arm64-darwin)
160
163
  sqlite3 (1.6.2-x86_64-darwin)
161
164
  thor (1.2.1)
162
165
  timeout (0.3.2)
@@ -168,6 +171,7 @@ GEM
168
171
  zeitwerk (2.6.7)
169
172
 
170
173
  PLATFORMS
174
+ arm64-darwin-21
171
175
  x86_64-darwin-19
172
176
 
173
177
  DEPENDENCIES
data/README.md CHANGED
@@ -55,6 +55,7 @@ pagy_cursor(Post.all, after: 10, order: {updated_at: :desc})
55
55
 
56
56
  Many thanks to:
57
57
  - [Uysim](https://github.com/Uysim)
58
+ - [Hirokazu Hata](https://github.com/h-michael)
58
59
  - [M. Yunan Helmy](https://github.com/yunanhelmy)
59
60
  - [Eumir Gaspar](https://github.com/corroded)
60
61
 
@@ -73,7 +74,7 @@ To run tests in root folder of gem:
73
74
  - ```bundle exec rspec ```
74
75
 
75
76
  To test on specific Rails version
76
- ```export BUNDLE_GEMFILE=gemfiles/active_record_52.gemfile``` to work with Rails 5.2
77
+ ```export BUNDLE_GEMFILE=gemfiles/active_record_70.gemfile``` to work with Rails 7
77
78
 
78
79
  To play with app cd test/dummy and rails s -b 0.0.0.0 (before rails db:migrate).
79
80
 
@@ -23,9 +23,22 @@ class Pagy
23
23
  if position.present?
24
24
  arel_table = pagy.arel_table
25
25
 
26
- select_created_at = arel_table.project(arel_table[:created_at]).where(arel_table[pagy.primary_key].eq(position))
27
- select_the_sample_created_at = arel_table[:created_at].eq(select_created_at).and(arel_table[pagy.primary_key].send(pagy.comparation, position))
28
- sql_comparation = arel_table[:created_at].send(pagy.comparation, select_created_at).or(select_the_sample_created_at)
26
+ # If the primary sort key is not "created_at"
27
+
28
+ # Select the primary sort key
29
+ # pagy.order should be something like:
30
+ # [:created_at, :id] or [:foo_column, ..., :created_at, :id]
31
+ primary_sort_key = pagy.order.keys.detect{ |order_key| ![:created_at, :id].include?(order_key.to_sym) } || :created_at
32
+
33
+ select_previous_row = arel_table.project(arel_table[primary_sort_key]).
34
+ where(arel_table[pagy.primary_key].eq(position))
35
+
36
+ sql_comparation = arel_table[primary_sort_key].
37
+ send(pagy.comparation, select_previous_row).
38
+ or(
39
+ arel_table[primary_sort_key].eq(select_previous_row).
40
+ and(arel_table[pagy.primary_key].send(pagy.comparation, position))
41
+ )
29
42
 
30
43
  collection = collection.where(sql_comparation)
31
44
  end
@@ -1,3 +1,3 @@
1
1
  module PagyCursor
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy_cursor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uysim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pagy