activerecord-cursor 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/activerecord/cursor/model_extension.rb +3 -4
- data/lib/activerecord/cursor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5468fa164f47c75c904c47a9d0db02d2646e71b5
|
4
|
+
data.tar.gz: 1e45fb4a1f00265a16a0b37176ead58af1b2c2c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b332c7fecc4403daca4be9d5be8b3365ff312ef4c8fafae00beefcd0874f818cf015dbfb339d5e3317aa85f1780a879f643f9c9b928cc4714e2a7065d579548
|
7
|
+
data.tar.gz: 285d945a97d383a5c05ff194afd6560fb7e25c5a1050740ac31a5a807642b72a89f56b370b8502530ca9a50f01cc660a966ee350faaf5e400709268054176c9d
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Post.all
|
|
29
29
|
#<Post id: 4, published: false, score: 2, created_at: "2018-12-30 19:38:30", updated_at: "2018-12-30 19:38:30">
|
30
30
|
]
|
31
31
|
Post.cursor(key: :created_at)
|
32
|
-
=> [#<Post id: 1, published: false, created_at: "2018-12-30 19:38:27", updated_at: "2018-12-30 19:38:27">]
|
32
|
+
=> [#<Post id: 1, published: false, score: 0, created_at: "2018-12-30 19:38:27", updated_at: "2018-12-30 19:38:27">]
|
33
33
|
Post.where(published: true).cursor(key: :created_at, reverse: true)
|
34
34
|
=> [#<Post id: 3, published: true, score: 1, created_at: "2018-12-30 19:38:29", updated_at: "2018-12-30 19:38:29">]
|
35
35
|
Post.where(published: true).cursor(key: :created_at, reverse: true, start: Post.next_cursor) # Get next page
|
@@ -42,7 +42,7 @@ module ActiveRecord
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def in_order
|
45
|
-
|
45
|
+
order("#{column} #{by}", "#{table_name}.id #{by}")
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -101,9 +101,8 @@ module ActiveRecord
|
|
101
101
|
record = @records[0]
|
102
102
|
@next = generate_cursor(record) if record
|
103
103
|
size = @records.size
|
104
|
-
|
105
|
-
|
106
|
-
end
|
104
|
+
reverse_by = by == 'asc' ? 'desc' : 'asc'
|
105
|
+
@records = @records.reorder("#{column} #{reverse_by}").limit(@options[:size])
|
107
106
|
return unless size == @options[:size] + 1
|
108
107
|
|
109
108
|
@prev = generate_cursor(record)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-cursor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomohiro Suwa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|