pattern_query_helper 0.1.9 → 0.1.10

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: caceb088a2059270acfce9119d5794089c9805b1
4
- data.tar.gz: 8e6916e46207d6cbc92d4c3eb15fecd9267e80d8
3
+ metadata.gz: b868a9d24784bf1635be621ee9ab43542f176774
4
+ data.tar.gz: e1595a029ff272c8c7fc8dfe872615b672ab40dc
5
5
  SHA512:
6
- metadata.gz: ea414de0fdecea3f2a786d75a5abfd5c7f16eb3664a24262832da73260d7a4b03819faad2dccdb01b2362b9f49bc1dad756021f29ae7eb9915c2446a9a8d4391
7
- data.tar.gz: df415343bc674682fc0684af8023bf91bab7737f637cae1704d57b7af468e8d740586921b24e8f452fcdee9db4eff64ec3642fd49547e3fe7dd2236021047002
6
+ metadata.gz: 267714428ec883cd37a8879ae59ca3442fbd20296012575d3b5cb84796535f6a22f74d14fa93ab56ff0bf1c97dff1bfb04d32f7c9eeba2c30285d2bb7955cd79
7
+ data.tar.gz: 0f84d630e8e6c7174b80135cb6a5e27a22f519d18131ca148545278f38e64abb97f1faa6a0a7b9a0e80593480863e118fe1d578aaf133299510703eeae42e0a5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pattern_query_helper (0.1.9)
4
+ pattern_query_helper (0.1.10)
5
5
  activerecord (~> 5.0)
6
6
  kaminari
7
7
 
@@ -66,9 +66,5 @@ module PatternQueryHelper
66
66
  }
67
67
 
68
68
  end
69
-
70
- def self.filter_active_record_query(active_record_call, filtering)
71
- active_record_call.where(filtering[:filter_string], filtering[:filter_params].symbolize_keys)
72
- end
73
69
  end
74
70
  end
@@ -1,3 +1,3 @@
1
1
  module PatternQueryHelper
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -18,13 +18,7 @@ module PatternQueryHelper
18
18
  end
19
19
 
20
20
  def self.run_active_record_query(active_record_call, query_helpers, single_record=false)
21
- if single_record
22
- single_record_active_record_query(active_record_call, query_helpers)
23
- elsif query_helpers[:per_page] || query_helpers[:page]
24
- paginated_active_record_query(active_record_call, query_helpers)
25
- else
26
- active_record_query(active_record_call, query_helpers)
27
- end
21
+ run_sql_query(active_record_call.model, active_record_call.to_sql, {}, query_helpers, single_record)
28
22
  end
29
23
 
30
24
  private
@@ -94,34 +88,6 @@ module PatternQueryHelper
94
88
  }
95
89
  end
96
90
 
97
- def self.active_record_query(active_record_call, query_helpers)
98
- query_helpers = parse_helpers(query_helpers)
99
- filtered_query = PatternQueryHelper::Filtering.filter_active_record_query(active_record_call, query_helpers[:filters])
100
- sorted_query = PatternQueryHelper::Sorting.sort_active_record_query(active_record_call, query_helpers[:sorting])
101
- with_associations = PatternQueryHelper::Associations.load_associations(sorted_query, query_helpers[:associations])
102
- {
103
- data: with_associations
104
- }
105
- end
106
-
107
- def self.paginated_active_record_query(active_record_call, query_helpers)
108
- query_helpers = parse_helpers(query_helpers)
109
- filtered_query = PatternQueryHelper::Filtering.filter_active_record_query(active_record_call, query_helpers[:filters])
110
- sorted_query = PatternQueryHelper::Sorting.sort_active_record_query(active_record_call, query_helpers[:sorting])
111
- paginated_query = PatternQueryHelper::Pagination.paginate_active_record_query(sorted_query, query_helpers[:pagination])
112
- with_associations = PatternQueryHelper::Associations.load_associations(paginated_query, query_helpers[:associations])
113
- count = ActiveRecord::Base.connection.execute(%{with query as (#{sorted_query.to_sql}) select count(*) as count from query}).first["count"].to_i
114
- pagination = PatternQueryHelper::Pagination.create_pagination_payload(count, query_helpers[:pagination])
115
- {
116
- pagination: pagination,
117
- data: with_associations
118
- }
119
- end
120
-
121
- def self.single_record_active_record_query(active_record_call, query_helpers)
122
- # TODO: Add Logic to this method
123
- end
124
-
125
91
  def self.parse_helpers(params)
126
92
  filtering = PatternQueryHelper::Filtering.create_filters(params[:filter])
127
93
  sorting = PatternQueryHelper::Sorting.parse_sorting_params(params[:sort])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan McDaniel