query_helper 0.2.13 → 0.2.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: b0971fc10b2b990185b05e538e41dcb898033baa6e9f3f59c22a5c024fead8bb
4
- data.tar.gz: 55e383eadc934c0ff9f1cb44236033b5c93b6d7b302210fc10eaff1c8e4d614f
3
+ metadata.gz: 1aceb412b2d8c65cbe7a8ca001c0d3609b926546a3928e996b9a8f68f3c59491
4
+ data.tar.gz: 28027fdaec7281917bf52578c2dcf36d390e4dbdecc71286f35453f30831fd2f
5
5
  SHA512:
6
- metadata.gz: 8f5c67987554c03af1a0cf2d6a72bc3e225463c33fc5e8b53fbc5689fe05888bcb364f702d771b47f23c1cf356b8c0a01d0c1c39e56afd9931e55c50cdc0d6a7
7
- data.tar.gz: 8a65504c1ba6e8f7f5088e6dcdbeb132b438781c63efec29eb79f527d0fb18919af1f4570f10be3e0453bea014892c3dd8372388c2f6e8b8a9b536197c3f683a
6
+ metadata.gz: 8a402b1afb054e8470ee020d354e581564940b27091f5d24cb7a0cd277e7fd20c26cc2e6e15211967bf993ea96346223e60fba4a07f39eda34720d23351eb58a
7
+ data.tar.gz: cae4fbd2f45abbd36df6393883897cf77d7451c8a86211085f48185ba0ad3d6dab68f3d196a757b49261afa4976137f4291acd825d63bebc2a81d9eff2893030
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- query_helper (0.2.13)
4
+ query_helper (0.2.14)
5
5
  activerecord (> 5)
6
6
  activesupport (> 5)
7
7
 
@@ -179,6 +179,29 @@ class QueryHelper
179
179
  return @results
180
180
  end
181
181
 
182
+ def pagination_results(count=@count)
183
+ # Set pagination params if they aren't provided
184
+ results_per_page = @per_page || count
185
+ results_page = @page || 1
186
+
187
+ total_pages = (count/(results_per_page.nonzero? || 1).to_f).ceil
188
+ next_page = results_page + 1 if results_page.between?(1, total_pages - 1)
189
+ previous_page = results_page - 1 if results_page.between?(2, total_pages)
190
+ first_page = results_page == 1
191
+ last_page = results_page == total_pages
192
+ out_of_range = !results_page.between?(1,total_pages)
193
+
194
+ { count: count,
195
+ current_page: results_page,
196
+ next_page: next_page,
197
+ previous_page: previous_page,
198
+ total_pages: total_pages,
199
+ per_page: results_per_page,
200
+ first_page: first_page,
201
+ last_page: last_page,
202
+ out_of_range: out_of_range }
203
+ end
204
+
182
205
  private
183
206
 
184
207
  def determine_page(page:, per_page:)
@@ -239,29 +262,6 @@ class QueryHelper
239
262
  @results.map!{ |r| r.except("_query_full_count") } if @page && @per_page && !@single_record
240
263
  end
241
264
 
242
- def pagination_results
243
- # Set pagination params if they aren't provided
244
- results_per_page = @per_page || @count
245
- results_page = @page || 1
246
-
247
- total_pages = (@count/(results_per_page.nonzero? || 1).to_f).ceil
248
- next_page = results_page + 1 if results_page.between?(1, total_pages - 1)
249
- previous_page = results_page - 1 if results_page.between?(2, total_pages)
250
- first_page = results_page == 1
251
- last_page = results_page == total_pages
252
- out_of_range = !results_page.between?(1,total_pages)
253
-
254
- { count: @count,
255
- current_page: results_page,
256
- next_page: next_page,
257
- previous_page: previous_page,
258
- total_pages: total_pages,
259
- per_page: results_per_page,
260
- first_page: first_page,
261
- last_page: last_page,
262
- out_of_range: out_of_range }
263
- end
264
-
265
265
  def create_column_maps
266
266
  ColumnMap.create_column_mappings(
267
267
  query: @query,
@@ -1,3 +1,3 @@
1
1
  class QueryHelper
2
- VERSION = "0.2.13"
2
+ VERSION = "0.2.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan McDaniel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-16 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler