manageiq-api-common 1.0.0 → 1.0.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
  SHA256:
3
- metadata.gz: 7aa3a3a98c142ee7b4e8e62af8acd12e08a86d189bf74ad2eb902b454c9b20bb
4
- data.tar.gz: eddfcfd2730f8a252a76482a72d213c2cdc18d887b3c6465d378bc8b9119a3f4
3
+ metadata.gz: 0c8d656cee54b8c74a2657c8102480ee5682a2af50f14d02ce345668425983db
4
+ data.tar.gz: 7204efad0cbab35cdbbb70eb046059fd1a5de69d6630a77c6806ba39125a30c2
5
5
  SHA512:
6
- metadata.gz: 6f7a9bbfaf5e56fc3f625d35e8a1e0f466e65581980a88a72d052e5d5d2bd472b0f1de63380b84cf678e85b12b03713fbaf84adb2b6d23544947cecb79200f3b
7
- data.tar.gz: 1e563fc8760b903a88f7dffcb7e3569400e84dc2b4f86a0e440c74b7bc191d4ced1b7162120401554d6bd1b7770ee9918b2f173636f6433975ab111c2a643876
6
+ metadata.gz: bf2b4452a59e4eea346b73eff624639ac10f93a1e361e44e5a9fe6985c9955c146484d1c7320cce950617c066c37e75a70fe33f41634f8942073ff6bf2d7abdf
7
+ data.tar.gz: b42783172cf71e6487d48ece8ca85bbd25322fa5a547e8953a2da52eab00c966910508aff6c4eeb85a3aff0cb6d9e1e3f683a95fb53df9edd25e6b35e75b0fbb
@@ -47,16 +47,17 @@ module ManageIQ
47
47
  end
48
48
 
49
49
  def link_to_prev
50
- return if current_limit_multiplier == 0
50
+ return if offset == 0
51
+ prev_offset = offset - limit
51
52
 
52
- link_with_new_offset((current_limit_multiplier - 1) * limit)
53
+ link_with_new_offset(prev_offset.clamp(0, Float::INFINITY))
53
54
  end
54
55
 
55
56
  def link_to_next
56
- next_limit_multiplier = current_limit_multiplier + 1
57
- return if next_limit_multiplier > max_limit_multiplier
57
+ next_offset = limit + offset
58
+ return if next_offset >= count
58
59
 
59
- link_with_new_offset(next_limit_multiplier * limit)
60
+ link_with_new_offset(next_offset)
60
61
  end
61
62
 
62
63
  def link_with_new_offset(offset)
@@ -75,10 +76,6 @@ module ManageIQ
75
76
  @request_uri ||= URI.parse(@request.original_url)
76
77
  end
77
78
 
78
- def current_limit_multiplier
79
- @current_limit_multiplier ||= offset / limit
80
- end
81
-
82
79
  def max_limit_multiplier
83
80
  @max_limit_multiplier ||= ((count - 1) / limit)
84
81
  end
@@ -1,7 +1,7 @@
1
1
  module ManageIQ
2
2
  module API
3
3
  module Common
4
- VERSION = "1.0.0".freeze
4
+ VERSION = "1.0.1".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-api-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-04 00:00:00.000000000 Z
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_tenant