ocean-rails 2.1.0 → 2.1.1

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
  SHA1:
3
- metadata.gz: ddd77052a13c531215d5a319c731f04a71b52641
4
- data.tar.gz: 1f6993cbf041b79efe6f58c7dca63fddd0a23ba4
3
+ metadata.gz: ee568551ab7cc1568b5a5f42ed9fb178059f454e
4
+ data.tar.gz: 8bcdd5311573411e7de5a5be71b7749a560c0986
5
5
  SHA512:
6
- metadata.gz: d190b929b801a83006b50a2f97022f97b46241233059c5e2d6e2ff3c398eefd0f894e64a2c4ef353b860665ed1fd2accc4cd19b436837d6ab75304c7b4730cbe
7
- data.tar.gz: 4c278e2e491ca601d85b5d1100223f80e3012dcb2d4a36c4c68cec5e50ce69bae167a17fbb673b2318d7bcfde2d4dc485239d70e3238b301fe301f0a74159fac
6
+ metadata.gz: 3d8ad03e2440314d32da75347424f88519f576190d269dd5157b0e0365f62a891231afe15962dee612e1682e562cf0eb3850a3bc5dcc1bd1257b06bfa96840c6
7
+ data.tar.gz: 511d8a48333a4b1309031a1e82c290b31fed9f2c35b2608a407e26c081cd170ad1eeec3ba6cf173bbb496db5fafd2322b20a12ab7b55ee1cfd61f6433fa86ed8
@@ -178,6 +178,10 @@ module OceanApplicationController
178
178
  locals: {m.class.model_name.i18n_key => m}) }
179
179
  count = resources.count
180
180
  total_count = x.unscope(:limit, :offset).count
181
+ # page = nil
182
+ # page_size = nil
183
+ # prev_page = nil
184
+ # next_page = nil
181
185
  attrs = {count: count,
182
186
  total_count: total_count
183
187
  }
@@ -187,7 +191,8 @@ module OceanApplicationController
187
191
  if params[:page]
188
192
  page = params[:page].to_i
189
193
  page_size = params[:page_size].to_i || x.collection_page_size
190
- last_page = (total_count / page_size).ceil
194
+ total_pages = (total_count.to_f / page_size.to_f).ceil
195
+ last_page = total_pages - 1
191
196
  prev_page = page > 0 && page - 1
192
197
  next_page = page != last_page && page + 1
193
198
  links['first_page'] = {href: url_for(params.merge(page: 0)), type: 'application/json'}
@@ -196,9 +201,12 @@ module OceanApplicationController
196
201
  links['next_page'] = {href: url_for(params.merge(page: next_page)), type: 'application/json'} if next_page
197
202
  end
198
203
  end
199
- if links
200
- attrs['_links'] = links
201
- end
204
+
205
+ attrs['_links'] = links if links
206
+ attrs['page'] = page if page
207
+ attrs['page_size'] = page_size if page_size
208
+ attrs['total_pages'] = total_pages if total_pages
209
+
202
210
  render text: '{"_collection":{"resources":[' + resources.join(',') + ']' +
203
211
  (attrs.collect do |k, v|
204
212
  ',"' + k.to_s + '":' + v.to_json
data/lib/ocean/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson