eivo-rails-api 0.1.10 → 0.1.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8362e17aaf35365ac1f318195f53ead6c07f67ae136f5d8330043582f293c5d
|
4
|
+
data.tar.gz: 15334f702a62f2f1ca0b8bb44ed28c0b20b74d87e6ef66139564f498abfdd0e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
@@ -52,9 +52,11 @@ module EIVO
|
|
52
52
|
render_errors json_errors.flatten
|
53
53
|
end
|
54
54
|
|
55
|
-
def render_error(code, status: :bad_request, source: nil)
|
55
|
+
def render_error(code, status: :bad_request, title: nil, detail: nil, source: nil)
|
56
56
|
render_errors([{
|
57
57
|
code: code,
|
58
|
+
title: title,
|
59
|
+
detail: detail,
|
58
60
|
source: source,
|
59
61
|
status: ::Rack::Utils::SYMBOL_TO_STATUS_CODE[status].to_s
|
60
62
|
}.compact], status: status)
|
@@ -16,13 +16,14 @@ if Rails.env.staging? || Rails.env.production?
|
|
16
16
|
config.lograge.ignore_actions = ['EIVO::StatusController#index']
|
17
17
|
|
18
18
|
config.lograge.custom_options = ->(event) do
|
19
|
-
result = {
|
20
|
-
params: event.payload[:params].except('controller', 'action', 'format'),
|
21
|
-
request_id: event.payload[:request_id]
|
22
|
-
}
|
19
|
+
result = event.payload.dup || {}
|
23
20
|
|
24
|
-
result
|
25
|
-
|
21
|
+
result.delete(:headers)
|
22
|
+
|
23
|
+
# Removed because already present in event.payload
|
24
|
+
if result[:params]
|
25
|
+
result[:params] = result[:params].except('controller', 'action', 'format')
|
26
|
+
end
|
26
27
|
|
27
28
|
# https://github.com/roidrage/lograge/pull/307
|
28
29
|
if event.respond_to?(:allocations)
|
data/eivo-rails-api.gemspec
CHANGED
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.
|
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:
|
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: []
|