pattern_query_helper 0.1.4 → 0.1.5
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/pattern_query_helper/version.rb +1 -1
- data/lib/pattern_query_helper.rb +36 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72dac5f490c67ea9ccbd91ccae154825800c6175
|
4
|
+
data.tar.gz: ce895e90962390309e933db424d3df56902defae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85bab3af7f4381aea91f70ed15759109d25f2dc3cb43f171d67d1a5396157c69c46cbc9143dd7114421957050f24c3451b204da3b0ab99bbe988afe3b8980d2e
|
7
|
+
data.tar.gz: 3e3a252834a9f418ecacdb16aa63027d9bc5b795319e77abd0ca3dc4a088de052716086536526e30e4ce314ef9865c243a0c0f643b480fb596d3ea2b0d6e7c87
|
data/Gemfile.lock
CHANGED
data/lib/pattern_query_helper.rb
CHANGED
@@ -6,8 +6,32 @@ require "pattern_query_helper/sorting"
|
|
6
6
|
require "pattern_query_helper/sql"
|
7
7
|
|
8
8
|
module PatternQueryHelper
|
9
|
-
def self.
|
10
|
-
|
9
|
+
def self.run_sql_query(model, query, query_params, query_helpers, query_type)
|
10
|
+
case query_type
|
11
|
+
when "single_record"
|
12
|
+
single_record_sql_query(model, query, query_params, query_helpers)
|
13
|
+
when "paginated"
|
14
|
+
paginated_sql_query(model, query, query_params, query_helpers)
|
15
|
+
when "all"
|
16
|
+
sql_query(model, query, query_params, query_helpers)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.run_active_record_query(active_record_call, query_helpers, query_type)
|
21
|
+
case query_type
|
22
|
+
when "single_record"
|
23
|
+
single_record_active_record_query(active_record_call, query_helpers)
|
24
|
+
when "paginated"
|
25
|
+
paginated_active_record_query(active_record_call, query_helpers)
|
26
|
+
when "all"
|
27
|
+
active_record_query(active_record_call, query_helpers)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.paginated_sql_query(model, query, query_params, query_helpers)
|
34
|
+
query_helpers = parse_helpers(query_helpers)
|
11
35
|
|
12
36
|
query_config = {
|
13
37
|
model: model,
|
@@ -31,8 +55,8 @@ module PatternQueryHelper
|
|
31
55
|
}
|
32
56
|
end
|
33
57
|
|
34
|
-
def self.sql_query(model, query, query_params,
|
35
|
-
query_helpers =
|
58
|
+
def self.sql_query(model, query, query_params, query_helpers)
|
59
|
+
query_helpers = parse_helpers(query_helpers)
|
36
60
|
|
37
61
|
query_config = {
|
38
62
|
model: model,
|
@@ -51,8 +75,8 @@ module PatternQueryHelper
|
|
51
75
|
}
|
52
76
|
end
|
53
77
|
|
54
|
-
def self.single_record_sql_query(model, query, query_params,
|
55
|
-
query_helpers =
|
78
|
+
def self.single_record_sql_query(model, query, query_params, query_helpers)
|
79
|
+
query_helpers = parse_helpers(query_helpers)
|
56
80
|
|
57
81
|
query_config = {
|
58
82
|
model: model,
|
@@ -71,8 +95,8 @@ module PatternQueryHelper
|
|
71
95
|
}
|
72
96
|
end
|
73
97
|
|
74
|
-
def self.active_record_query(active_record_call,
|
75
|
-
query_helpers =
|
98
|
+
def self.active_record_query(active_record_call, query_helpers)
|
99
|
+
query_helpers = parse_helpers(query_helpers)
|
76
100
|
filtered_query = PatternQueryHelper::Filtering.filter_active_record_query(active_record_call, query_helpers[:filters])
|
77
101
|
sorted_query = PatternQueryHelper::Sorting.sort_active_record_query(active_record_call, query_helpers[:sorting])
|
78
102
|
with_associations = PatternQueryHelper::Associations.load_associations(sorted_query, query_helpers[:associations])
|
@@ -81,8 +105,8 @@ module PatternQueryHelper
|
|
81
105
|
}
|
82
106
|
end
|
83
107
|
|
84
|
-
def self.paginated_active_record_query(active_record_call,
|
85
|
-
query_helpers =
|
108
|
+
def self.paginated_active_record_query(active_record_call, query_helpers)
|
109
|
+
query_helpers = parse_helpers(query_helpers)
|
86
110
|
filtered_query = PatternQueryHelper::Filtering.filter_active_record_query(active_record_call, query_helpers[:filters])
|
87
111
|
sorted_query = PatternQueryHelper::Sorting.sort_active_record_query(active_record_call, query_helpers[:sorting])
|
88
112
|
paginated_query = PatternQueryHelper::Pagination.paginate_active_record_query(sorted_query, query_helpers[:pagination])
|
@@ -94,11 +118,11 @@ module PatternQueryHelper
|
|
94
118
|
}
|
95
119
|
end
|
96
120
|
|
97
|
-
def self.single_record_active_record_query
|
121
|
+
def self.single_record_active_record_query(active_record_call, query_helpers)
|
98
122
|
# TODO: Add Logic to this method
|
99
123
|
end
|
100
124
|
|
101
|
-
def self.
|
125
|
+
def self.parse_helpers(params)
|
102
126
|
filtering = PatternQueryHelper::Filtering.create_filters(params)
|
103
127
|
sorting = PatternQueryHelper::Sorting.parse_sorting_params(params)
|
104
128
|
associations = PatternQueryHelper::Associations.process_association_params(params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pattern_query_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan McDaniel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|