Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jul 28, 2024
2 parents 76ffd63 + ae1d906 commit 78949da
Show file tree
Hide file tree
Showing 57 changed files with 331 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body:
attributes:
label: 👀 Before submitting...
options:
- label: I upgraded to pagy version 9.0.2
- label: I upgraded to pagy version 9.0.3
required: true
- label: I searched through the [Documentation](https://ddnexus.github.io/pagy/)
required: true
Expand Down
12 changes: 7 additions & 5 deletions .github/latest_release_body.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
- See the [Changelog](https://ddnexus.github.io/pagy/changelog) for possible breaking changes
<!-- whats_new_end -->

### Changes in 9.0.2
### Changes in 9.0.3

<!-- changes_start -->
- Rename and document the link header to pagy_link_header
- Add first and next url helpers to the keyset extra; add the keyset section to config/pagy.rb
- Fix nil page in keyset URL not overriding the params page
- Extracted shared method
- Remove legacy and unused javascript files
- Improve pagy_get_page with force_integer option
- Fix jsonapi with keyset
- Complete the internal refactoring of version 9:
- Remove the pagy*_get_vars methods now useless
- Use to_i on the page variable for the search extras
<!-- changes_end -->

[CHANGELOG](https://ddnexus.github.io/pagy/changelog)
8 changes: 4 additions & 4 deletions .idea/runConfigurations/Bump_Version.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ If you upgrade from version `< 9.0.0` see the following:
- None
<hr>

## Version 9.0.3

- Remove legacy and unused javascript files
- Improve pagy_get_page with force_integer option
- Fix jsonapi with keyset
- Complete the internal refactoring of version 9:
- Remove the pagy*_get_vars methods now useless
- Use to_i on the page variable for the search extras

## Version 9.0.2

- Rename and document the link header to pagy_link_header
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: gem
specs:
pagy (9.0.2)
pagy (9.0.3)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -91,7 +91,7 @@ GEM
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
docile (1.4.0)
docile (1.4.1)
domain_name (0.6.20240107)
drb (2.2.1)
erubi (1.13.0)
Expand Down Expand Up @@ -157,9 +157,9 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.6-x86_64-darwin)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
oj (3.16.4)
bigdecimal (>= 3.0)
Expand All @@ -169,7 +169,7 @@ GEM
racc
psych (5.1.2)
stringio
public_suffix (6.0.0)
public_suffix (6.0.1)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.8.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md

Large diffs are not rendered by default.

Binary file modified bun.lockb
Binary file not shown.
23 changes: 1 addition & 22 deletions docs/api/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ and [meilisearch](/docs/extras/meilisearch.md) extras for specific backend custo
```ruby Controller
include Pagy::Backend

# optional overriding of some sub-method
def pagy_get_vars(collection, **vars)
#...
end

# use it in some action
def index
@pagy, @records = pagy(Product.some_scope, some_option: 'some option for this instance')
Expand All @@ -60,26 +55,10 @@ the `Pagy.new` method) and returns the `Pagy` instance and the page of records.
@pagy, @records = pagy(Product.my_scope, some_option: 'get merged in the pagy object')
```

The built-in `pagy` method is designed to be easy to customize by overriding any of the two sub-methods that it calls internally.
You can independently change the default variables (`pagy_get_vars`) and/or the default page of items from the
collection `pagy_get_items`).

The built-in `pagy` method is designed to be easy to customize by overriding any sub-methods that it calls internally.
If you need to use multiple different types of collections in the same app or action, you may want to define some alternative and
self contained custom `pagy` method. (see [Writing your own Pagy methods](#writing-your-own-pagy-methods))

==- `pagy_get_vars(collection, vars)`

Sub-method called only by the `pagy` method, it returns the hash of variables used to initialize the Pagy object.

Override it if you need to add or change some variable. For example you may want to add the `:item_name` in order to customize
the output _(see [How to customize the item name](/docs/how-to.md#customize-the-item-name))_.

!!!warning Don't remove `:count` and `:page`
If you override it, remember that `:count` and `:page` are the only 2 required Pagy core variables, so be careful not to remove them from the returned hash.
!!!

See also the [How To](/docs/how-to.md) page for some usage examples.

==- `pagy_get_count(collection, vars)`

Get the count from the collection, considering also the `:count_args` variable. Override it if you need to calculate the count in some special way, or cache it. e.g. overriding [`pagy_get_count` when using mongoid](../how-to/#override-pagy_get_count-use-count_documents-with-mongoid).
Expand Down
11 changes: 3 additions & 8 deletions docs/extras/arel.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ require 'pagy/extras/arel'
This method is the same as the generic `pagy` method, but with improved speed for SQL `GROUP BY` collections. (see
the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil))

==- `pagy_arel_get_vars(collection)`

This sub-method is the same as the `pagy_get_vars` sub-method, but it is called only by the `pagy_arel` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

==- `pagy_arel_count(collection)`

This sub-method it is called only by the `pagy_get_vars` method. It will detect which query to perform based on the active record
groups (sql `GROUP BY`s). In case there aren't group values performs a normal `.count(:all)`, otherwise it will perform
a `COUNT(*) OVER ()`. The last tells database to perform a count of all the lines after the `GROUP BY` clause is applied.
This sub-method detects which query to perform based on the active record groups (sql `GROUP BY`s). In case there aren't
group values performs a normal `.count(:all)`, otherwise it will perform a `COUNT(*) OVER ()`. The last tells database to
perform a count of all the lines after the `GROUP BY` clause is applied.

===
5 changes: 0 additions & 5 deletions docs/extras/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,4 @@ require 'pagy/extras/array'
This method is the same as the generic `pagy` method, but specialized for an Array. (see
the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil))

==- `pagy_array_get_vars(array)`

This sub-method is the same as the `pagy_get_vars` sub-method, but it is called only by the `pagy_array` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

===
5 changes: 0 additions & 5 deletions docs/extras/countless.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ This mode is enabled by the `:countless_minimal` variable.
This method is the same as the generic `pagy` method (see the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil)), however
its returned objects will depend on the value of the `:countless_minimal` variable (see [Modes](#modes))

==- `pagy_countless_get_vars(_collection, vars)`

This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_countless` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

==- `pagy_countless_get_items(collection, pagy)`

This sub-method is similar to the `pagy_get_items` sub-method, but it is called only by the `pagy_countless` method. (see
Expand Down
5 changes: 0 additions & 5 deletions docs/extras/elasticsearch_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,4 @@ the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil)).

It expects to receive `YourModel.pagy_search(...)` result and returns the paginated response.

==- `pagy_elasticsearch_rails_get_vars(array)`

This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_elasticsearch_rails` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

===
6 changes: 0 additions & 6 deletions docs/extras/keyset.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ See the [Pagy::Keyset variables](/docs/api/keyset.md#variables)
This method is similar to the offset `pagy` method. It returns the `pagy` object (instance of `Pagy::Keyset::ActiveRecord` or
`Pagy::Keyset::Sequel`, depending on the set class) and the array of `records` pulled from the DB.

==- `pagy_keyset_get_vars(vars)`

This sub-method is internally called only by the `pagy_keyset` method. It automatically sets the `:page` variable and - if you
use the [limit extra](limit.md) also the `:limit` variables from the request `params`. Documented only for
overriding.

==- `pagy_keyset_first_url(pagy, absolute: false)`

Return the first page URL string. (See also the [headers](headers.md) and [jsonapi](jsonapi.md) extras for more complete solutions)
Expand Down
5 changes: 0 additions & 5 deletions docs/extras/meilisearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,4 @@ the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil))

It expects to receive `YourModel.pagy_search(...)` result and returns the paginated response.

==- `pagy_meilisearch_get_vars(array)`

This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_meilisearch` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

===
5 changes: 0 additions & 5 deletions docs/extras/searchkick.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,4 @@ the [pagy doc](/docs/api/backend.md#pagy-collection-vars-nil))

It expects to receive `YourModel.pagy_search(...)` result and returns the paginated response.

==- `pagy_searchkick_get_vars(array)`

This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_searchkick` method. (see
the [pagy_get_vars doc](/docs/api/backend.md#pagy-get-vars-collection-vars)).

===
4 changes: 2 additions & 2 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ of gaps) you should override the `series` method. See more details and examples

## Pass the page number

You don't need to explicitly pass the page number to the `pagy` method, because it is pulled in by the `pagy_get_vars` (which is
You don't need to explicitly pass the page number to the `pagy` method, because it is pulled in by the `pagy_get_page` (which is
called internally by the `pagy` method). However you can force a `page` number by just passing it to the `pagy` method. For
example:

Expand Down Expand Up @@ -619,7 +619,7 @@ from 301 to 315 for the last page.

## Paginate non-ActiveRecord collections

The `pagy_get_vars` method works out of the box with `ActiveRecord` collections; for other collections (e.g. `mongoid`, etc.)
The `pagy_get_count` method works out of the box with `ActiveRecord` collections; for other collections (e.g. `mongoid`, etc.)
you might want to change the `:count_args` default to suite your ORM count method:

```ruby pagy.rb (initializer)
Expand Down
2 changes: 1 addition & 1 deletion gem/apps/calendar.ru
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# DOC
# https://ddnexus.github.io/pagy/playground/#5-calendar-app

VERSION = '9.0.2'
VERSION = '9.0.3'

# Gemfile
require 'bundler/inline'
Expand Down
2 changes: 1 addition & 1 deletion gem/apps/demo.ru
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# DOC
# https://ddnexus.github.io/pagy/playground/#3-demo-app

VERSION = '9.0.2'
VERSION = '9.0.3'

require 'bundler/inline'
require 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion gem/apps/rails.ru
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# DOC
# https://ddnexus.github.io/pagy/playground/#2-rails-app

VERSION = '9.0.2'
VERSION = '9.0.3'

# Gemfile
require 'bundler/inline'
Expand Down
2 changes: 1 addition & 1 deletion gem/apps/repro.ru
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# DOC
# https://ddnexus.github.io/pagy/playground/#1-repro-app

VERSION = '9.0.2'
VERSION = '9.0.3'

require 'bundler/inline'
require 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion gem/bin/pagy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

VERSION = '9.0.2'
VERSION = '9.0.3'
APPS = %w[repro rails demo calendar keyset_ar keyset_s].freeze
LINUX = RbConfig::CONFIG['host_os'].include?('linux')
HOST = '0.0.0.0'
Expand Down
2 changes: 1 addition & 1 deletion gem/config/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Pagy initializer file (9.0.2)
# Pagy initializer file (9.0.3)
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
# Should you just cherry pick part of this file, please maintain the require-order of the extras

Expand Down
Loading

0 comments on commit 78949da

Please sign in to comment.