simple_drilldown 0.14.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 +14 -4
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +1 -1
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,7 +155,7 @@ 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')
|
@@ -163,7 +163,7 @@ module SimpleDrilldown
|
|
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 = where
|
166
|
+
where_mapped = realized_where(where)
|
167
167
|
rows_query = rows_query.where(where_mapped)
|
168
168
|
end
|
169
169
|
rows = rows_query.to_a
|
@@ -184,6 +184,15 @@ module SimpleDrilldown
|
|
184
184
|
end
|
185
185
|
end
|
186
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
|
+
|
187
196
|
def make_conditions(search_filter)
|
188
197
|
includes = c_base_includes.dup
|
189
198
|
if search_filter
|
@@ -393,7 +402,7 @@ module SimpleDrilldown
|
|
393
402
|
group = nil if group.empty?
|
394
403
|
|
395
404
|
joins = self.class.make_join([], c_target_class.name.underscore.to_sym, includes)
|
396
|
-
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)
|
397
406
|
row_query = row_query.where(conditions) if conditions
|
398
407
|
rows = row_query.joins(joins).group(group).order(order).to_a
|
399
408
|
if rows.empty?
|
@@ -598,7 +607,8 @@ module SimpleDrilldown
|
|
598
607
|
end
|
599
608
|
joins = self.class.make_join([], c_target_class.name.underscore.to_sym, list_includes)
|
600
609
|
list_conditions = list_conditions(conditions, values)
|
601
|
-
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)
|
602
612
|
base_query = base_query.where(list_conditions) if list_conditions
|
603
613
|
result[:records] = base_query.to_a
|
604
614
|
end
|