incline 0.2.25 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/incline/data_tables_request.rb +35 -7
- data/lib/incline/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f450825492e9998e61730273f23eece45027fa0a
|
4
|
+
data.tar.gz: 65c8d04ee7f53deed946071c433c4c4dd00a3637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c007bdc0c21cc51f28d0eb267ade695f70f8e29a70eaf8cde1e33ccea72fd14e8d0add429b1e568fa52df7f034a4b012c4d863aa0f6b5c594c814fc3fdd139
|
7
|
+
data.tar.gz: e8989b1486b14dcc7edb05ce44cafbc5bf98e96b20cbb9e56e5a70ef53d573118f75b7949108f089c6f6814c27c09d06bb98c8cb075ea204d60ed120a0a62ad5
|
data/Gemfile.lock
CHANGED
@@ -260,7 +260,10 @@ module Incline
|
|
260
260
|
columns.reject {|c| !c[:searchable] || relation.model.column_names.include?(c[:name].to_s) }.any?
|
261
261
|
)
|
262
262
|
|
263
|
-
|
263
|
+
order_local = ordering.blank? || ordering.reject{|k,_| relation.model.column_names.include?(k.to_s)}.any?
|
264
|
+
|
265
|
+
Incline::Log::debug "Filtering will be done #{(filter_local || order_local) ? 'application' : 'database'}-side."
|
266
|
+
Incline::Log::debug "Ordering will be done #{order_local ? 'application' : 'database'}-side."
|
264
267
|
|
265
268
|
unless filter_local
|
266
269
|
### Database Side Individual Filtering (AND) ###
|
@@ -282,19 +285,23 @@ module Incline
|
|
282
285
|
end
|
283
286
|
|
284
287
|
### Database Side Ordering ###
|
285
|
-
|
286
|
-
relation = relation.order(id: :asc)
|
287
|
-
else
|
288
|
+
unless order_local
|
288
289
|
relation = relation.order(ordering)
|
289
290
|
end
|
290
291
|
|
291
|
-
# Now we have two paths, if we are filtering locally, we need to return everything up to this point and
|
292
|
+
# Now we have two paths, if we are filtering/ordering locally, we need to return everything up to this point and
|
292
293
|
# perform our filters before limiting the results.
|
293
|
-
# If we filtered at the database, then we can limit the results there as well.
|
294
|
-
if filter_local
|
294
|
+
# If we filtered and ordered at the database, then we can limit the results there as well.
|
295
|
+
if filter_local || order_local
|
295
296
|
# execute the query
|
296
297
|
relation = relation.to_a
|
297
298
|
|
299
|
+
### Application Side Ordering ###
|
300
|
+
if order_local
|
301
|
+
ordering_list = ordering.to_a
|
302
|
+
relation.sort{|a,b| local_sort(a, b, ordering_list) }
|
303
|
+
end
|
304
|
+
|
298
305
|
### Local Individual Filtering (AND) ###
|
299
306
|
columns.reject{|c| c[:search].blank? || c[:name].blank?}.each do |col|
|
300
307
|
name = col[:name].to_s
|
@@ -351,5 +358,26 @@ module Incline
|
|
351
358
|
end
|
352
359
|
end
|
353
360
|
|
361
|
+
private
|
362
|
+
|
363
|
+
def local_sort(a, b, attribs, index = 0)
|
364
|
+
if index >= attribs.count
|
365
|
+
0
|
366
|
+
else
|
367
|
+
attr, dir = attribs[index]
|
368
|
+
val_a = a.send(attr)
|
369
|
+
val_b = b.send(attr)
|
370
|
+
if val_a == val_b
|
371
|
+
local_sort a, b, attribs, index + 1
|
372
|
+
else
|
373
|
+
if dir.to_s.downcase == 'desc'
|
374
|
+
val_b <=> val_a
|
375
|
+
else
|
376
|
+
val_a <=> val_b
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
354
382
|
end
|
355
383
|
end
|
data/lib/incline/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beau Barker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -610,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
610
610
|
version: '0'
|
611
611
|
requirements: []
|
612
612
|
rubyforge_project:
|
613
|
-
rubygems_version: 2.
|
613
|
+
rubygems_version: 2.6.11
|
614
614
|
signing_key:
|
615
615
|
specification_version: 4
|
616
616
|
summary: A gem designed to get off to an even quicker start with Rails.
|