query_helper 0.2.19 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +22 -20
- data/lib/query_helper.rb +2 -0
- data/lib/query_helper/query_helper_concern.rb +2 -2
- data/lib/query_helper/sql_sort.rb +16 -6
- data/lib/query_helper/version.rb +1 -1
- data/query_helper.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ef59e4a5c449b359942acdf2577f6e756aa24df46175ab7c066a878d737a3e
|
4
|
+
data.tar.gz: 155d7aedaeb4b2da6ae1984217307dbb7144e19565cc28d1fdd920879adb4c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ee0d63818c17954054138587d5d6a49a175119bb37432e4c99952f638b8f39c4b81130e14eaf9e51e6715cb3fcd4527b23382c2caef7721f05dbe874cab07f6
|
7
|
+
data.tar.gz: 2295b50557aa7d74c9d713c4cfd4732f479fca0c026f101e9969562c7c8f68fe762324a4215c40cc722abfa0129e062ef995a504b3f060f6842ce27013cf9185
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
query_helper (0.2.
|
4
|
+
query_helper (0.2.20)
|
5
5
|
activerecord (> 5)
|
6
6
|
activesupport (> 5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionpack (6.0.3.
|
12
|
-
actionview (= 6.0.3.
|
13
|
-
activesupport (= 6.0.3.
|
11
|
+
actionpack (6.0.3.5)
|
12
|
+
actionview (= 6.0.3.5)
|
13
|
+
activesupport (= 6.0.3.5)
|
14
14
|
rack (~> 2.0, >= 2.0.8)
|
15
15
|
rack-test (>= 0.6.3)
|
16
16
|
rails-dom-testing (~> 2.0)
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
-
actionview (6.0.3.
|
19
|
-
activesupport (= 6.0.3.
|
18
|
+
actionview (6.0.3.5)
|
19
|
+
activesupport (= 6.0.3.5)
|
20
20
|
builder (~> 3.1)
|
21
21
|
erubi (~> 1.4)
|
22
22
|
rails-dom-testing (~> 2.0)
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
-
activemodel (6.0.3.
|
25
|
-
activesupport (= 6.0.3.
|
26
|
-
activerecord (6.0.3.
|
27
|
-
activemodel (= 6.0.3.
|
28
|
-
activesupport (= 6.0.3.
|
29
|
-
activesupport (6.0.3.
|
24
|
+
activemodel (6.0.3.5)
|
25
|
+
activesupport (= 6.0.3.5)
|
26
|
+
activerecord (6.0.3.5)
|
27
|
+
activemodel (= 6.0.3.5)
|
28
|
+
activesupport (= 6.0.3.5)
|
29
|
+
activesupport (6.0.3.5)
|
30
30
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
31
31
|
i18n (>= 0.7, < 2)
|
32
32
|
minitest (~> 5.1)
|
@@ -46,10 +46,12 @@ GEM
|
|
46
46
|
crass (~> 1.0.2)
|
47
47
|
nokogiri (>= 1.5.9)
|
48
48
|
method_source (1.0.0)
|
49
|
-
mini_portile2 (2.
|
49
|
+
mini_portile2 (2.5.0)
|
50
50
|
minitest (5.14.1)
|
51
|
-
nokogiri (1.
|
52
|
-
mini_portile2 (~> 2.
|
51
|
+
nokogiri (1.11.1)
|
52
|
+
mini_portile2 (~> 2.5.0)
|
53
|
+
racc (~> 1.4)
|
54
|
+
racc (1.5.2)
|
53
55
|
rack (2.2.3)
|
54
56
|
rack-test (1.1.0)
|
55
57
|
rack (>= 1.0, < 3)
|
@@ -58,9 +60,9 @@ GEM
|
|
58
60
|
nokogiri (>= 1.6)
|
59
61
|
rails-html-sanitizer (1.3.0)
|
60
62
|
loofah (~> 2.3)
|
61
|
-
railties (6.0.3.
|
62
|
-
actionpack (= 6.0.3.
|
63
|
-
activesupport (= 6.0.3.
|
63
|
+
railties (6.0.3.5)
|
64
|
+
actionpack (= 6.0.3.5)
|
65
|
+
activesupport (= 6.0.3.5)
|
64
66
|
method_source
|
65
67
|
rake (>= 0.8.7)
|
66
68
|
thor (>= 0.20.3, < 2.0)
|
@@ -99,7 +101,7 @@ PLATFORMS
|
|
99
101
|
DEPENDENCIES
|
100
102
|
actionpack
|
101
103
|
activesupport
|
102
|
-
bundler (~>
|
104
|
+
bundler (~> 2.2.6)
|
103
105
|
byebug
|
104
106
|
faker (~> 1.9.3)
|
105
107
|
query_helper!
|
@@ -109,4 +111,4 @@ DEPENDENCIES
|
|
109
111
|
sqlite3 (~> 1.3.6)
|
110
112
|
|
111
113
|
BUNDLED WITH
|
112
|
-
|
114
|
+
2.2.6
|
data/lib/query_helper.rb
CHANGED
@@ -66,6 +66,7 @@ class QueryHelper
|
|
66
66
|
search_fields: nil,
|
67
67
|
sql_filter: nil,
|
68
68
|
sql_sort: nil,
|
69
|
+
sort_tiebreak: nil,
|
69
70
|
page: nil,
|
70
71
|
per_page: nil,
|
71
72
|
search_string: nil,
|
@@ -83,6 +84,7 @@ class QueryHelper
|
|
83
84
|
@search_fields = search_fields if search_fields
|
84
85
|
@sql_filter = sql_filter if sql_filter
|
85
86
|
@sql_sort = sql_sort if sql_sort
|
87
|
+
@sql_sort.sort_tiebreak = sort_tiebreak if sort_tiebreak
|
86
88
|
@search_string = search_string if search_string
|
87
89
|
@page = determine_page(page: page, per_page: per_page) if page
|
88
90
|
@per_page = determine_per_page(page: page, per_page: per_page) if per_page
|
@@ -31,7 +31,7 @@ class QueryHelper
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def create_query_helper_sort
|
34
|
-
QueryHelper::SqlSort.new(sort_string: params[:sort])
|
34
|
+
QueryHelper::SqlSort.new(sort_string: params[:sort], sort_tiebreak: params[:sort_tiebreak])
|
35
35
|
end
|
36
36
|
|
37
37
|
def create_query_helper_associations
|
@@ -48,7 +48,7 @@ class QueryHelper
|
|
48
48
|
def query_helper_params_no_pagination
|
49
49
|
helpers = {}
|
50
50
|
helpers[:sql_filter] = create_query_helper_filter() if params[:filter]
|
51
|
-
helpers[:sql_sort] = create_query_helper_sort() if params[:sort]
|
51
|
+
helpers[:sql_sort] = create_query_helper_sort() if params[:sort] || params[:sort_tiebreak]
|
52
52
|
helpers[:associations] = create_query_helper_associations() if params[:include]
|
53
53
|
helpers[:search_string] = params[:search_for] if params[:search_for]
|
54
54
|
helpers
|
@@ -3,22 +3,33 @@ require "query_helper/invalid_query_error"
|
|
3
3
|
class QueryHelper
|
4
4
|
class SqlSort
|
5
5
|
|
6
|
-
attr_accessor :column_maps, :select_strings
|
6
|
+
attr_accessor :column_maps, :select_strings, :sort_tiebreak
|
7
7
|
|
8
|
-
def initialize(sort_string: "", column_maps: [])
|
8
|
+
def initialize(sort_string: "", sort_tiebreak: "", column_maps: [])
|
9
9
|
@sort_string = sort_string
|
10
10
|
@column_maps = column_maps
|
11
|
+
@sort_tiebreak = sort_tiebreak
|
11
12
|
@select_strings = []
|
12
13
|
end
|
13
14
|
|
14
15
|
def parse_sort_string
|
16
|
+
return [] if @sort_string.blank? && @sort_tiebreak.blank?
|
17
|
+
|
18
|
+
return attributes_sql_expression(@sort_tiebreak) if @sort_string.blank?
|
19
|
+
|
20
|
+
sql_strings = attributes_sql_expression(@sort_string)
|
21
|
+
return sql_strings if @sort_tiebreak.blank?
|
22
|
+
|
23
|
+
sql_strings + attributes_sql_expression(@sort_tiebreak)
|
24
|
+
end
|
25
|
+
|
26
|
+
def attributes_sql_expression(sort_attribute)
|
15
27
|
sql_strings = []
|
16
|
-
sorts =
|
28
|
+
sorts = sort_attribute.split(",")
|
17
29
|
sorts.each_with_index do |sort, index|
|
18
30
|
sort_alias = sort.split(":")[0]
|
19
31
|
direction = sort.split(":")[1]
|
20
32
|
modifier = sort.split(":")[2]
|
21
|
-
|
22
33
|
begin
|
23
34
|
sql_expression = @column_maps.find{ |m| m.alias_name == sort_alias }.sql_expression
|
24
35
|
rescue NoMethodError => e
|
@@ -45,8 +56,7 @@ class QueryHelper
|
|
45
56
|
|
46
57
|
sql_strings << "#{sql_expression} #{direction}"
|
47
58
|
end
|
48
|
-
|
49
|
-
return sql_strings
|
59
|
+
sql_strings
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
data/lib/query_helper/version.rb
CHANGED
data/query_helper.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
|
-
spec.add_development_dependency "bundler", "~>
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.2.6"
|
40
40
|
spec.add_development_dependency "rake", "~> 13.0"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
42
42
|
spec.add_development_dependency "sqlite3", "~> 1.3.6"
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan McDaniel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.6
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,7 +199,7 @@ homepage: https://github.com/iserve-products/query_helper
|
|
199
199
|
licenses:
|
200
200
|
- MIT
|
201
201
|
metadata: {}
|
202
|
-
post_install_message:
|
202
|
+
post_install_message:
|
203
203
|
rdoc_options: []
|
204
204
|
require_paths:
|
205
205
|
- lib
|
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
218
|
-
signing_key:
|
217
|
+
rubygems_version: 3.1.4
|
218
|
+
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Ruby Gem to help with pagination and data formatting at Pattern, Inc.
|
221
221
|
test_files: []
|