simple_drilldown 0.13.0 → 0.14.1

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
  SHA256:
3
- metadata.gz: c6f8406ee9ef7580adc175f3995a79bcb428f954e4d84012ad0a0180b6cf7996
4
- data.tar.gz: cfd5b6a19277aac5e11443a0c7429bc741991e2da00c1915ddff1b6554df75c3
3
+ metadata.gz: ef72a1d7f488dd64e45e610dafbef583ed0be5c3e65ae1a4fe024350efc5bde9
4
+ data.tar.gz: 356bbee827c123946e2ec7d75891b81454f862ed57d1ba88bddc210b47e94884
5
5
  SHA512:
6
- metadata.gz: 930779fb380dcff0933a71df90bfa3d55f7ca43103f68d30e89d380f6dc68ac5cb6ae6accd32d98bba445179e6498b0143b4d235e98aa0649b94ed20c5b04de6
7
- data.tar.gz: c54be58a2c0c072e70884b73ce88daceb8c3e6508f921c06eaa67011a93d52ebc9624b462e47c393397ee285325b8f8a05eb8cdfee5dc6eb8247054c939e4605
6
+ metadata.gz: f3a2390ecacca9bd85ce30e768aa662917f4b165df4f77e45cccfbb3201cb43548bc4cfd21052d0e835f1ed58a1770dd3d92f66283792aed86f5001e3171676b
7
+ data.tar.gz: ee791c11f609c1ca18dd95405c80be69c73e7a8ba79ba4cb4b4dd32164f49f93224f2a22ec8e452aeb71ccf60c709e66ae00a7f4433c587ab25d97c2b08979b0
@@ -155,14 +155,17 @@ module SimpleDrilldown
155
155
  dimension_def = c_dimension_defs[field.to_s]
156
156
  result_sets = dimension_def[:queries].map do |query|
157
157
  includes = merge_includes(includes, query[:includes]) if query[:includes]
158
- rows_query = c_target_class.unscoped.where(c_base_condition)
158
+ rows_query = c_target_class.unscoped.where(realized_where(c_base_condition))
159
159
  .select("#{query[:select]} AS value")
160
160
  .joins(make_join([], c_target_class.name.underscore.to_sym, includes))
161
161
  .order('value')
162
162
  .group(:value)
163
163
  rows_query = rows_query.without_deleted if c_target_class.try :paranoid?
164
164
  rows_query = rows_query.where(filter_conditions) if filter_conditions
165
- rows_query = rows_query.where(query[:where]) if query[:where]
165
+ if (where = query[:where])
166
+ where_mapped = realized_where(where)
167
+ rows_query = rows_query.where(where_mapped)
168
+ end
166
169
  rows = rows_query.to_a
167
170
  filter_fields = search.filter[field.to_s]
168
171
  filter_fields&.each do |selected_value|
@@ -181,6 +184,15 @@ module SimpleDrilldown
181
184
  end
182
185
  end
183
186
 
187
+ def realized_where(where)
188
+ case where
189
+ when Array
190
+ where.map { |e| e.respond_to?(:call) ? e.call : e }
191
+ else
192
+ where
193
+ end
194
+ end
195
+
184
196
  def make_conditions(search_filter)
185
197
  includes = c_base_includes.dup
186
198
  if search_filter
@@ -192,6 +204,13 @@ module SimpleDrilldown
192
204
  dimension_def = c_dimension_defs[field]
193
205
  raise "Unknown filter field: #{field.inspect}" if dimension_def.nil?
194
206
 
207
+ dimension_def[:queries].each do |query|
208
+ next unless (where = query[:where])
209
+
210
+ where_mapped = where.map { |e| e.respond_to?(:call) ? e.call : e }
211
+ condition_strings << where_mapped[0]
212
+ condition_values += where_mapped[1..]
213
+ end
195
214
  values = Array(values)
196
215
  if dimension_def[:interval]
197
216
  if values[0].present? && values[1].present?
@@ -383,7 +402,7 @@ module SimpleDrilldown
383
402
  group = nil if group.empty?
384
403
 
385
404
  joins = self.class.make_join([], c_target_class.name.underscore.to_sym, includes)
386
- row_query = c_target_class.unscoped.where(c_base_condition).select(select)
405
+ row_query = c_target_class.unscoped.where(self.class.realized_where(c_base_condition)).select(select)
387
406
  row_query = row_query.where(conditions) if conditions
388
407
  rows = row_query.joins(joins).group(group).order(order).to_a
389
408
  if rows.empty?
@@ -588,7 +607,8 @@ module SimpleDrilldown
588
607
  end
589
608
  joins = self.class.make_join([], c_target_class.name.underscore.to_sym, list_includes)
590
609
  list_conditions = list_conditions(conditions, values)
591
- base_query = c_target_class.unscoped.where(c_base_condition).joins(joins).order(c_list_order)
610
+ base_query = c_target_class.unscoped.where(self.class.realized_where(c_base_condition)).joins(joins)
611
+ .order(c_list_order)
592
612
  base_query = base_query.where(list_conditions) if list_conditions
593
613
  result[:records] = base_query.to_a
594
614
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleDrilldown
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_drilldown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-29 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx_rails