eivo-rails-api 0.1.13 → 0.1.14

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: 9a7fec1b66e25e2c1aef85dd8d18b1b69a83cefb4d47494fae2d73b8dec21089
4
- data.tar.gz: 2fdae83eb7d5d86676ca3dfd077d90c2be93064e54e24800d88f7fc6e378ae59
3
+ metadata.gz: b8362e17aaf35365ac1f318195f53ead6c07f67ae136f5d8330043582f293c5d
4
+ data.tar.gz: 15334f702a62f2f1ca0b8bb44ed28c0b20b74d87e6ef66139564f498abfdd0e0
5
5
  SHA512:
6
- metadata.gz: f5bf240b46c716222cd59c69ff698545c1dd009a6bd58dd51af1f81479e0815da8f91e57042d9f9551bf23e234ba67b4a07b390f24aaf5fbd86200b336146d6b
7
- data.tar.gz: fd533ff30d8182382764fa799150c7b342d08040e9b261f5c1ff28a8e99463b6a138badf800a5ef3880e95f49ca122f50c83077dc4304611faa70b16ed9cb0ec
6
+ metadata.gz: 0c0941d7283903837f7e051039167872bd3c3ce9f118cd25883556155798373db0d53777ef6efc21d7d71d50635f9224de10d35358060caea7f834a3ff8c6b1a
7
+ data.tar.gz: 8396499cf5728012a59f3c9c4be2afbc53ff2b80250114c0663594230ff47a4376b95b6201fb32b49185cb35c78545ae7c87866139b2c0498b01fe12b02c1099
@@ -5,7 +5,7 @@ module EIVO
5
5
  module Pagination
6
6
  extend ::ActiveSupport::Concern
7
7
 
8
- def paginate(collection)
8
+ def paginate(collection, options = {})
9
9
  unless ::ActiveModel::Type::Boolean.new.cast(params[:pagination]) == false
10
10
  limit = 50
11
11
  if params[:limit]
@@ -22,22 +22,32 @@ module EIVO
22
22
  def pagination_options(collection)
23
23
  options = {
24
24
  is_collection: true,
25
- meta: {
26
- total: collection.total_count,
27
- pages: collection.total_pages
28
- },
29
25
  links: {
30
26
  self: url_for(params.to_unsafe_h.merge(page: collection.current_page)),
31
27
  first: url_for(params.to_unsafe_h.merge(page: 1)),
32
- last: url_for(params.to_unsafe_h.merge(page: collection.total_pages))
33
28
  }
34
29
  }
35
30
 
36
- if !collection.out_of_range? && !collection.first_page?
37
- options[:links][:prev] = url_for(params.to_unsafe_h.merge(page: collection.prev_page))
38
- end
39
- if !collection.out_of_range? && !collection.last_page?
40
- options[:links][:next] = url_for(params.to_unsafe_h.merge(page: collection.next_page))
31
+ # avoid count request on large table
32
+ if params[:pagination] == 'infinite'
33
+ options[:links][:next] = url_for(params.to_unsafe_h.merge(page: collection.current_page + 1))
34
+
35
+ if !collection.first_page?
36
+ options[:links][:prev] = url_for(params.to_unsafe_h.merge(page: collection.current_page - 1))
37
+ end
38
+ else
39
+ options[:links][:last] = url_for(params.to_unsafe_h.merge(page: collection.total_pages))
40
+ options[:meta] = {
41
+ total: collection.total_count,
42
+ pages: collection.total_pages
43
+ }
44
+
45
+ if !collection.out_of_range? && !collection.last_page?
46
+ options[:links][:next] = url_for(params.to_unsafe_h.merge(page: collection.next_page))
47
+ end
48
+ if !collection.out_of_range? && !collection.first_page?
49
+ options[:links][:prev] = url_for(params.to_unsafe_h.merge(page: collection.prev_page))
50
+ end
41
51
  end
42
52
 
43
53
  options
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'eivo-rails-api'
7
- spec.version = '0.1.13'
7
+ spec.version = '0.1.14'
8
8
  spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
9
9
  spec.email = ['jonathan@eivo.co']
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eivo-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan VUKOVICH-TRIBOUHARET
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-04 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -218,7 +218,7 @@ homepage: https://www.eivo.co
218
218
  licenses:
219
219
  - MIT
220
220
  metadata: {}
221
- post_install_message:
221
+ post_install_message:
222
222
  rdoc_options: []
223
223
  require_paths:
224
224
  - lib
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  requirements: []
236
236
  rubygems_version: 3.1.2
237
- signing_key:
237
+ signing_key:
238
238
  specification_version: 4
239
239
  summary: EIVO Rails API
240
240
  test_files: []