mongoid-scroll 2.0.0 → 2.0.1
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 +4 -4
- data/.github/workflows/ci.yml +18 -17
- data/.github/workflows/danger-comment.yml +9 -0
- data/.github/workflows/danger.yml +9 -15
- data/CHANGELOG.md +7 -0
- data/Dangerfile +5 -1
- data/Gemfile +13 -5
- data/README.md +3 -2
- data/RELEASING.md +31 -47
- data/examples/feed.rb +1 -0
- data/lib/mongoid/criteria/scrollable/fields.rb +6 -0
- data/lib/mongoid/criteria/scrollable.rb +1 -1
- data/lib/mongoid/scroll/version.rb +1 -1
- data/spec/mongoid/criteria_spec.rb +31 -0
- data/spec/spec_helper.rb +8 -4
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9e2af0b05c25202ce0f2c1e87b760a0d41c7f534c0675f90a513e249949b503
|
|
4
|
+
data.tar.gz: 83b648b0c1c8073ef6cf3dccdaa071051784f95b6db85ecddc079e30706e512a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9582fb4fb8da92db5d65fbb076578bb0ff732e2073c7e0f1c095deee6fe399939712917752ac4f656ea81937f986d0475d622f3193fbeef56f35a1e4b306cc53
|
|
7
|
+
data.tar.gz: a245b4f08c1546e92b9ed1bc8d260391a935ad3d2079f5d7eaa8effe0954da187b1cf6f12846bc9aefe05a4e2475aeda4fc952ef611e209e3a637ce99d0bf908
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,6 +5,7 @@ jobs:
|
|
|
5
5
|
test:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
7
|
strategy:
|
|
8
|
+
fail-fast: false
|
|
8
9
|
matrix:
|
|
9
10
|
entry:
|
|
10
11
|
- { ruby: '2.7', mongodb: '4.4', mongoid: '6' }
|
|
@@ -19,15 +20,23 @@ jobs:
|
|
|
19
20
|
- { ruby: '3.2', mongodb: '7.0', mongoid: '8' }
|
|
20
21
|
- { ruby: '3.3', mongodb: '6.0', mongoid: '9' }
|
|
21
22
|
- { ruby: '3.3', mongodb: '7.0', mongoid: '9' }
|
|
23
|
+
- { ruby: '3.4', mongodb: '8.0', mongoid: '9' }
|
|
24
|
+
- { ruby: '4.0', mongodb: '8.0', mongoid: '9', coverage: 'true' }
|
|
22
25
|
name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}), mongoid=${{ matrix.entry.mongoid }})
|
|
23
26
|
env:
|
|
24
27
|
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
|
|
28
|
+
COVERAGE: ${{ matrix.entry.coverage }}
|
|
29
|
+
services:
|
|
30
|
+
mongodb:
|
|
31
|
+
image: mongo:${{ matrix.entry.mongodb }}
|
|
32
|
+
ports: ['27017:27017']
|
|
33
|
+
options: >-
|
|
34
|
+
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
|
|
35
|
+
--health-interval 10s
|
|
36
|
+
--health-timeout 5s
|
|
37
|
+
--health-retries 10
|
|
25
38
|
steps:
|
|
26
|
-
-
|
|
27
|
-
uses: supercharge/mongodb-github-action@1.8.0
|
|
28
|
-
with:
|
|
29
|
-
mongodb-version: ${{ matrix.entry.mongodb }}
|
|
30
|
-
- uses: actions/checkout@v3
|
|
39
|
+
- uses: actions/checkout@v7
|
|
31
40
|
- name: Set up Ruby
|
|
32
41
|
uses: ruby/setup-ruby@v1
|
|
33
42
|
with:
|
|
@@ -38,17 +47,9 @@ jobs:
|
|
|
38
47
|
- name: Run examples
|
|
39
48
|
run: bundle exec ruby examples/feed.rb
|
|
40
49
|
- name: Report Coverage
|
|
50
|
+
if: ${{ matrix.entry.coverage == 'true' }}
|
|
41
51
|
uses: coverallsapp/github-action@v2
|
|
42
52
|
with:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
upload-coverage:
|
|
47
|
-
needs: test
|
|
48
|
-
if: ${{ always() }}
|
|
49
|
-
runs-on: ubuntu-latest
|
|
50
|
-
steps:
|
|
51
|
-
- name: Upload Code Coverage Report
|
|
52
|
-
uses: coverallsapp/github-action@v2
|
|
53
|
-
with:
|
|
54
|
-
parallel-finished: true
|
|
53
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
54
|
+
file: coverage/.resultset.json
|
|
55
|
+
format: simplecov
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
name:
|
|
2
|
-
on:
|
|
1
|
+
name: Danger
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, reopened, edited, synchronize]
|
|
3
5
|
jobs:
|
|
4
6
|
danger:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- uses: ruby/setup-ruby@v1
|
|
11
|
-
with:
|
|
12
|
-
ruby-version: 2.7
|
|
13
|
-
bundler-cache: true
|
|
14
|
-
- run: |
|
|
15
|
-
# Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
|
|
16
|
-
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
|
|
17
|
-
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
|
7
|
+
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
|
|
8
|
+
with:
|
|
9
|
+
ruby-version: '3.4'
|
|
10
|
+
bundler-cache: true
|
|
11
|
+
secrets: inherit
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### 2.0.1 (2026/10/15)
|
|
2
|
+
|
|
3
|
+
* [#48](https://github.com/mongoid/mongoid-scroll/issues/48): Raise `NoSuchFieldError` when a sort or cursor refers to a field no longer defined on the model - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#51](https://github.com/mongoid/mongoid-scroll/pull/51): Report SimpleCov coverage to Coveralls once per build without duplicate gem uploads and refresh CI and coverage badges - [@dblock](https://github.com/dblock).
|
|
5
|
+
* [#50](https://github.com/mongoid/mongoid-scroll/pull/50): Modernize CI through Ruby 4.0, Mongoid 9 and MongoDB 8; fix Mongoid 9 dependency selection, database cleaner compatibility and invalid Danger workflow references - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#49](https://github.com/mongoid/mongoid-scroll/pull/49): Migrate Danger to danger-pr-comment workflow - [@dblock](https://github.com/dblock).
|
|
7
|
+
|
|
1
8
|
### 2.0.0 (2024/09/07)
|
|
2
9
|
|
|
3
10
|
* [#38](https://github.com/mongoid/mongoid-scroll/pull/38): Add `previous_cursor` - [@GCorbel](https://github.com/GCorbel).
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
source '
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
case version = ENV['MONGOID_VERSION'] || '
|
|
5
|
+
case version = ENV['MONGOID_VERSION'] || '9'
|
|
6
6
|
when 'HEAD' then gem 'mongoid', github: 'mongodb/mongoid'
|
|
7
|
+
when /^9/ then gem 'mongoid', '~> 9.0'
|
|
7
8
|
when /8/ then gem 'mongoid', '~> 8.0'
|
|
8
9
|
when /7/ then gem 'mongoid', '~> 7.0'
|
|
9
10
|
when /6/ then gem 'mongoid', '~> 6.0'
|
|
@@ -11,14 +12,21 @@ else gem 'mongoid', version
|
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
group :development, :test do
|
|
15
|
+
gem 'base64'
|
|
16
|
+
gem 'benchmark'
|
|
17
|
+
gem 'bigdecimal'
|
|
14
18
|
gem 'bundler'
|
|
15
|
-
gem '
|
|
16
|
-
gem '
|
|
19
|
+
gem 'danger', require: false
|
|
20
|
+
gem 'danger-changelog', require: false
|
|
21
|
+
gem 'danger-pr-comment', require: false
|
|
22
|
+
gem 'database_cleaner-mongoid', '~> 2.0'
|
|
17
23
|
gem 'faker'
|
|
18
|
-
gem '
|
|
24
|
+
gem 'logger'
|
|
25
|
+
gem 'mutex_m'
|
|
19
26
|
gem 'rake'
|
|
20
27
|
gem 'rspec', '~> 3.0'
|
|
21
28
|
gem 'rspec-its'
|
|
29
|
+
gem 'simplecov', '>= 0.22', require: false
|
|
22
30
|
gem 'rubocop', '1.66.1'
|
|
23
31
|
gem 'rubocop-rake'
|
|
24
32
|
gem 'rubocop-rspec'
|
data/README.md
CHANGED
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
# Mongoid::Scroll
|
|
15
15
|
|
|
16
16
|
[](https://badge.fury.io/rb/mongoid-scroll)
|
|
17
|
-
[](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml?query=branch%3Amaster)
|
|
18
18
|
[](https://coveralls.io/github/mongoid/mongoid-scroll?branch=master)
|
|
19
|
-
[](https://codeclimate.com/github/mongoid/mongoid-scroll)
|
|
20
19
|
|
|
21
20
|
Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `Mongo::Collection::View`.
|
|
22
21
|
|
|
@@ -75,6 +74,8 @@ end
|
|
|
75
74
|
|
|
76
75
|
Resume iterating using the saved cursor and save the cursor to go backwards.
|
|
77
76
|
|
|
77
|
+
If the sort field or a saved cursor's field is no longer defined on the model, `scroll` raises `Mongoid::Scroll::Errors::NoSuchFieldError`. A defined field with a `nil` value is not considered missing.
|
|
78
|
+
|
|
78
79
|
```ruby
|
|
79
80
|
Feed::Item.desc(:position).limit(5).scroll(saved_iterator.next_cursor) do |record, iterator|
|
|
80
81
|
# each record, one-by-one
|
data/RELEASING.md
CHANGED
|
@@ -1,64 +1,48 @@
|
|
|
1
|
-
Releasing Mongoid::Scroll
|
|
2
|
-
=========================
|
|
1
|
+
# Releasing Mongoid::Scroll
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Use the upstream checkout on clean `master`, verify `origin` is `mongoid/mongoid-scroll`, and run `git pull --ff-only`. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Prepare
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Set `lib/mongoid/scroll/version.rb` to the release version, date its `CHANGELOG.md` section using `YYYY/MM/DD`, and remove the contribution placeholder.
|
|
9
8
|
|
|
10
|
-
```
|
|
9
|
+
```sh
|
|
11
10
|
bundle install
|
|
12
|
-
rake
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Check that the last build succeeded in [Github Actions](https://github.com/mongoid/mongoid-scroll/actions) for all supported platforms.
|
|
16
|
-
|
|
17
|
-
Check that the version in [lib/mongoid/scroll/version.rb](lib/mongoid/scroll/version.rb) is the one you are releasing.
|
|
18
|
-
|
|
19
|
-
Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
### 0.4.0 (2018/12/24)
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Remove the line with "* Your contribution here.", since there will be no more contributions to this release.
|
|
26
|
-
|
|
27
|
-
Commit your changes.
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
git add CHANGELOG.md lib/mongoid-scroll/version.rb
|
|
31
|
-
git commit -m "Preparing for release, 0.4.0."
|
|
11
|
+
bundle exec rake
|
|
12
|
+
git add CHANGELOG.md lib/mongoid/scroll/version.rb RELEASING.md
|
|
13
|
+
git commit -m "Preparing for release, 2.0.1."
|
|
32
14
|
git push origin master
|
|
33
15
|
```
|
|
34
16
|
|
|
35
|
-
|
|
17
|
+
## Publish RubyGems and GitHub
|
|
36
18
|
|
|
19
|
+
```sh
|
|
20
|
+
bundle exec rake release
|
|
37
21
|
```
|
|
38
|
-
$ rake release
|
|
39
22
|
|
|
40
|
-
|
|
41
|
-
Tagged v0.4.0.
|
|
42
|
-
Pushed git commits and tags.
|
|
43
|
-
Pushed mongoid-scroll 0.4.0 to rubygems.org.
|
|
44
|
-
```
|
|
23
|
+
The task builds the gem, pushes its tag, and publishes to RubyGems. Complete MFA when prompted. If interrupted, inspect the tag and RubyGems version before retrying; never move a published tag. If only publication is missing, resume with `gem push pkg/mongoid-scroll-2.0.1.gem`.
|
|
45
24
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
|
25
|
+
A tag is not a GitHub release. After confirming RubyGems publication, create the matching GitHub release with changelog notes:
|
|
49
26
|
|
|
27
|
+
```sh
|
|
28
|
+
version=2.0.1
|
|
29
|
+
notes="$(mktemp)"
|
|
30
|
+
awk -v version="$version" '
|
|
31
|
+
/^### / {
|
|
32
|
+
if (found) exit
|
|
33
|
+
if ($2 == version) found = 1
|
|
34
|
+
next
|
|
35
|
+
}
|
|
36
|
+
found { print }
|
|
37
|
+
' CHANGELOG.md > "$notes"
|
|
38
|
+
gh release create "v$version" --repo mongoid/mongoid-scroll --verify-tag --title "$version" --notes-file "$notes" --latest
|
|
39
|
+
rm "$notes"
|
|
40
|
+
curl --fail --silent --show-error "https://rubygems.org/api/v2/rubygems/mongoid-scroll/versions/$version.json"
|
|
41
|
+
gh release view "v$version" --repo mongoid/mongoid-scroll
|
|
50
42
|
```
|
|
51
|
-
### 0.4.1 (Next)
|
|
52
43
|
|
|
53
|
-
|
|
54
|
-
```
|
|
44
|
+
Verify both the published gem and non-draft GitHub release before declaring completion.
|
|
55
45
|
|
|
56
|
-
|
|
46
|
+
## Prepare the Next Version
|
|
57
47
|
|
|
58
|
-
Commit
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
git add CHANGELOG.md lib/mongoid-scroll/version.rb
|
|
62
|
-
git commit -m "Preparing for next release, 0.4.1."
|
|
63
|
-
git push origin master
|
|
64
|
-
```
|
|
48
|
+
Increment the development patch version in `lib/mongoid/scroll/version.rb` (for example, `2.0.2`). Add `### 2.0.2 (Next)` with a contribution placeholder above the released changelog section. Commit and push those changes to `master`, leaving the released tag unchanged.
|
data/examples/feed.rb
CHANGED
|
@@ -5,12 +5,18 @@ module Mongoid
|
|
|
5
5
|
module Fields
|
|
6
6
|
private
|
|
7
7
|
|
|
8
|
+
def scroll_model_field(field_name)
|
|
9
|
+
klass.fields[field_name.to_s] ||
|
|
10
|
+
raise(Mongoid::Scroll::Errors::NoSuchFieldError.new(field: field_name))
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
def raise_mismatched_sort_fields_error!(cursor, criteria_cursor_options)
|
|
9
14
|
diff = cursor.sort_options.reject { |k, v| criteria_cursor_options[k] == v }
|
|
10
15
|
raise Mongoid::Scroll::Errors::MismatchedSortFieldsError.new(diff: diff)
|
|
11
16
|
end
|
|
12
17
|
|
|
13
18
|
def different_sort_fields?(cursor, criteria_cursor_options)
|
|
19
|
+
scroll_model_field(cursor.field_name)
|
|
14
20
|
criteria_cursor_options[:field_type] = criteria_cursor_options[:field_type].to_s
|
|
15
21
|
criteria_cursor_options[:field_name] = criteria_cursor_options[:field_name].to_s
|
|
16
22
|
criteria_cursor_options != cursor.sort_options
|
|
@@ -92,7 +92,7 @@ module Mongoid
|
|
|
92
92
|
|
|
93
93
|
def scroll_field_type(criteria)
|
|
94
94
|
scroll_field = scroll_field(criteria)
|
|
95
|
-
field =
|
|
95
|
+
field = scroll_model_field(scroll_field)
|
|
96
96
|
field.foreign_key? && field.object_id_field? ? BSON::ObjectId : field.type
|
|
97
97
|
end
|
|
98
98
|
end
|
|
@@ -42,6 +42,37 @@ describe Mongoid::Criteria do
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
context 'with a missing field' do
|
|
46
|
+
it 'rejects a sort field that is not defined on the model' do
|
|
47
|
+
expect do
|
|
48
|
+
Feed::Item.asc(:removed_field).scroll(cursor_type)
|
|
49
|
+
end.to raise_error Mongoid::Scroll::Errors::NoSuchFieldError, /does not exist: removed_field/
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'rejects a cursor whose field is no longer defined on the model' do
|
|
53
|
+
cursor = cursor_type.new(nil, field_name: 'removed_field', field_type: String)
|
|
54
|
+
expect do
|
|
55
|
+
Feed::Item.asc(:name).scroll(cursor)
|
|
56
|
+
end.to raise_error Mongoid::Scroll::Errors::NoSuchFieldError, /does not exist: removed_field/
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'does not confuse a nil field value with a missing field' do
|
|
60
|
+
record = Feed::Item.create!
|
|
61
|
+
cursor = cursor_type.from_record(record, field: record.fields['name'])
|
|
62
|
+
expect { Feed::Item.asc(:name).scroll(cursor) }.not_to raise_error
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if cursor_type == Mongoid::Scroll::Base64EncodedCursor
|
|
66
|
+
it 'rejects a serialized cursor whose field is no longer defined on the model' do
|
|
67
|
+
cursor = cursor_type.new(nil, field_name: 'removed_field', field_type: String)
|
|
68
|
+
saved_cursor = cursor_type.new(cursor.to_s)
|
|
69
|
+
expect do
|
|
70
|
+
Feed::Item.asc(:name).scroll(saved_cursor)
|
|
71
|
+
end.to raise_error Mongoid::Scroll::Errors::NoSuchFieldError, /does not exist: removed_field/
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
45
76
|
context 'with data' do
|
|
46
77
|
before do
|
|
47
78
|
10.times do |i|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
if ENV['COVERAGE'] == 'true'
|
|
5
|
+
require 'simplecov'
|
|
6
|
+
SimpleCov.start do
|
|
7
|
+
track_files 'lib/**/*.rb'
|
|
8
|
+
add_filter '/spec/'
|
|
9
|
+
end
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
require 'rubygems'
|
|
10
13
|
require 'rspec'
|
|
11
14
|
require 'rspec/its'
|
|
12
|
-
require '
|
|
15
|
+
require 'logger'
|
|
16
|
+
require 'database_cleaner/mongoid'
|
|
13
17
|
require 'mongoid-scroll'
|
|
14
18
|
|
|
15
19
|
Time.zone ||= 'EST'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-scroll
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Doubrovkine
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: i18n
|
|
@@ -46,6 +46,7 @@ extensions: []
|
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
48
|
- ".github/workflows/ci.yml"
|
|
49
|
+
- ".github/workflows/danger-comment.yml"
|
|
49
50
|
- ".github/workflows/danger.yml"
|
|
50
51
|
- ".gitignore"
|
|
51
52
|
- ".rspec"
|
|
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
111
112
|
- !ruby/object:Gem::Version
|
|
112
113
|
version: 1.3.6
|
|
113
114
|
requirements: []
|
|
114
|
-
rubygems_version: 3.
|
|
115
|
+
rubygems_version: 3.5.16
|
|
115
116
|
signing_key:
|
|
116
117
|
specification_version: 4
|
|
117
118
|
summary: Mongoid extensions to enable infinite scroll.
|