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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/query_helper.rb +23 -23
- data/lib/query_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aceb412b2d8c65cbe7a8ca001c0d3609b926546a3928e996b9a8f68f3c59491
|
4
|
+
data.tar.gz: 28027fdaec7281917bf52578c2dcf36d390e4dbdecc71286f35453f30831fd2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a402b1afb054e8470ee020d354e581564940b27091f5d24cb7a0cd277e7fd20c26cc2e6e15211967bf993ea96346223e60fba4a07f39eda34720d23351eb58a
|
7
|
+
data.tar.gz: cae4fbd2f45abbd36df6393883897cf77d7451c8a86211085f48185ba0ad3d6dab68f3d196a757b49261afa4976137f4291acd825d63bebc2a81d9eff2893030
|
data/Gemfile.lock
CHANGED
data/lib/query_helper.rb
CHANGED
@@ -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,
|
data/lib/query_helper/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|