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 +4 -4
- data/lib/simple_drilldown/controller.rb +24 -4
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef72a1d7f488dd64e45e610dafbef583ed0be5c3e65ae1a4fe024350efc5bde9
|
4
|
+
data.tar.gz: 356bbee827c123946e2ec7d75891b81454f862ed57d1ba88bddc210b47e94884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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)
|
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
|
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.
|
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-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx_rails
|