toast 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toast/collection_request.rb +5 -9
- data/lib/toast/plural_assoc_request.rb +5 -9
- data/lib/toast/request_helpers.rb +1 -1
- data/lib/toast/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: ef2a1167b071463b05602eafb1512b3e3ec8ad16
|
4
|
+
data.tar.gz: 49aff897ffcca410526d3ad99a932f71223dfcec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9119ba7f10a88228e1a88c11a313e1cfb9c3308c6d665c36b67adc0fe0595b87042320b6464820733dbe087c16b1eb1f1b4d6b37e80c07edc2bf3ba2b7084277
|
7
|
+
data.tar.gz: 7dc4fd2e26e3a3aefc19930244d1dcf15b4be3856757a2c3ce992c00671ea07d55e19b8afadcd2d2b1177ea128a8267da549eaa8b6056eac787a628a4bc6e4b1
|
@@ -51,6 +51,8 @@ class Toast::CollectionRequest
|
|
51
51
|
if relation.is_a?(ActiveRecord::Relation) and
|
52
52
|
relation.model == @config.base_model_class
|
53
53
|
|
54
|
+
result = relation.limit(window).offset(range_start)
|
55
|
+
|
54
56
|
# count = relation.count doesn't always work
|
55
57
|
# fix problematic select extensions for counting (-> { select(...) })
|
56
58
|
# this fails if the where clause depends on the the extended select
|
@@ -58,19 +60,13 @@ class Toast::CollectionRequest
|
|
58
60
|
headers = {"Content-Type" => @config.media_type}
|
59
61
|
|
60
62
|
if count > 0
|
61
|
-
|
62
|
-
count - 1
|
63
|
-
else
|
64
|
-
(range_start + window - 1)
|
65
|
-
end
|
66
|
-
|
67
|
-
headers[ "Content-Range"] = "items=#{range_start}-#{range_end}/#{count}"
|
63
|
+
headers["Content-Range"] = "items=#{range_start}-#{range_start + result.length - 1}/#{count}"
|
68
64
|
end
|
69
65
|
|
70
66
|
response :ok,
|
71
67
|
headers: headers,
|
72
|
-
body: represent(
|
73
|
-
msg: "sent #{
|
68
|
+
body: represent(result, @base_config),
|
69
|
+
msg: "sent #{result.length} records of #{@base_config.model_class}"
|
74
70
|
|
75
71
|
else
|
76
72
|
# wrong class/model_class
|
@@ -60,6 +60,8 @@ class Toast::PluralAssocRequest
|
|
60
60
|
|
61
61
|
call_allow(@config.via_get.permissions, @auth, source, @uri_params) # may raise NotAllowed, AllowError
|
62
62
|
|
63
|
+
result = relation.limit(window).offset(range_start)
|
64
|
+
|
63
65
|
# count = relation.count doesn't always work
|
64
66
|
# fix problematic select extensions for counting (-> { select(...) })
|
65
67
|
# this fails if the where clause depends on the the extended select
|
@@ -70,19 +72,13 @@ class Toast::PluralAssocRequest
|
|
70
72
|
headers = {"Content-Type" => @config.media_type}
|
71
73
|
|
72
74
|
if count > 0
|
73
|
-
|
74
|
-
count - 1
|
75
|
-
else
|
76
|
-
(range_start + window - 1)
|
77
|
-
end
|
78
|
-
|
79
|
-
headers[ "Content-Range"] = "items=#{range_start}-#{range_end}/#{count}"
|
75
|
+
headers["Content-Range"] = "items=#{range_start}-#{range_start + result.length - 1}/#{count}"
|
80
76
|
end
|
81
77
|
|
82
78
|
response :ok,
|
83
79
|
headers: headers,
|
84
|
-
body: represent(
|
85
|
-
msg: "sent #{
|
80
|
+
body: represent(result, target_config),
|
81
|
+
msg: "sent #{result.length} records of #{target_config.model_class}"
|
86
82
|
|
87
83
|
|
88
84
|
rescue ActiveRecord::RecordNotFound
|
@@ -90,7 +90,7 @@ module Toast::RequestHelpers
|
|
90
90
|
#
|
91
91
|
# Return: Rack conform response
|
92
92
|
def response status_sym, headers: {}, msg: nil, body: nil
|
93
|
-
Toast.logger.info "[#{Thread.current.object_id}] done:
|
93
|
+
Toast.logger.info "[#{Thread.current.object_id}] done: #{msg}"
|
94
94
|
|
95
95
|
unless Rails.env == 'production'
|
96
96
|
# put message in body, too, if body is free
|
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robokopp (Robert Annies)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|