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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00f3d3a35d3c3e1123335893dce1b17183837755
4
- data.tar.gz: 9501bcba0adb2f201071cf838bbbf8b96a0fd78c
3
+ metadata.gz: 72dac5f490c67ea9ccbd91ccae154825800c6175
4
+ data.tar.gz: ce895e90962390309e933db424d3df56902defae
5
5
  SHA512:
6
- metadata.gz: bde00eec48f1826ef48947c52ebe0bac4c1f7c8c3050e9adfdddbfbfc0a096cfc4b43a0bb8e879be8109f2482e7fa394a6f839d991264e0ff60456dc0dc21e27
7
- data.tar.gz: 9d668688ad2f803a8316c9efcca8522eed6bada340dea22a7afcd05eb596eb8ff9b955b6f05146850168f9e55a306ea4e8995f185f16d3b953e35a937f7eafd2
6
+ metadata.gz: 85bab3af7f4381aea91f70ed15759109d25f2dc3cb43f171d67d1a5396157c69c46cbc9143dd7114421957050f24c3451b204da3b0ab99bbe988afe3b8980d2e
7
+ data.tar.gz: 3e3a252834a9f418ecacdb16aa63027d9bc5b795319e77abd0ca3dc4a088de052716086536526e30e4ce314ef9865c243a0c0f643b480fb596d3ea2b0d6e7c87
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pattern_query_helper (0.1.4)
4
+ pattern_query_helper (0.1.5)
5
5
  activerecord (~> 5.0)
6
6
  kaminari
7
7
 
@@ -1,3 +1,3 @@
1
1
  module PatternQueryHelper
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -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.paginated_sql_query(model, query, query_params, url_params)
10
- query_helpers = parse_params(url_params)
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, url_params)
35
- query_helpers = parse_params(url_params)
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, url_params)
55
- query_helpers = parse_params(url_params)
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, url_params)
75
- query_helpers = parse_params(url_params)
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, url_params)
85
- query_helpers = parse_params(url_params)
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.parse_params(params)
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
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-26 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler