simple_drilldown 0.9.11 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/drilldown/data_2.builder +1 -1
- data/app/views/drilldown/data_3.builder +1 -1
- data/app/views/drilldown/excel_export_xlsx.xlsx.axlsx +1 -1
- data/lib/simple_drilldown/controller.rb +53 -57
- data/lib/simple_drilldown/helper.rb +2 -2
- data/lib/simple_drilldown/search.rb +1 -1
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f10c93cd2049eaa829e29002181350220b204776e6144abdf9ccb4a099f0410
|
|
4
|
+
data.tar.gz: 78f94e8d4d20eec48892fbd917fbc7b72d563d4707aac2c85b94c491f66e884c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c95c74daefab61fe569b0aa45717d11a47d47a5ffd77e885cfbcc3b3b22063a50e9ba8609b7d128445984417eda7eafe85f21344f9b4831059fe368662e4fac7
|
|
7
|
+
data.tar.gz: 3432bc0565e8fef78ff48a9dffb0f73dfd95872ba233fb91987942667878e55c1b326367998e7f8cc9f3d6a05d655c663b731167bdc4d2a55df426aa5b142bd8
|
|
@@ -4,7 +4,7 @@ xml.chart(
|
|
|
4
4
|
xAxisName: (@dimensions[0][:pretty_name] || 'Elections').gsub("'", ''), palette: '2',
|
|
5
5
|
caption: caption, subcaption: subcaption,
|
|
6
6
|
showNames: '1',
|
|
7
|
-
showValues: @result[:rows].size > 15 || @result[:rows][0] && @result[:rows][0][:rows].size > 4 ? 0 : 1,
|
|
7
|
+
showValues: @result[:rows].size > 15 || (@result[:rows][0] && @result[:rows][0][:rows].size > 4) ? 0 : 1,
|
|
8
8
|
decimals: '0',
|
|
9
9
|
numberPrefix: '', clustered: '0', exeTime: '1.5', showPlotBorder: '0', zGapPlot: '30',
|
|
10
10
|
zDepth: '90', divLineEffect: 'emboss', startAngX: '10', endAngX: '18', startAngY: '-10',
|
|
@@ -5,7 +5,7 @@ xml.chart(
|
|
|
5
5
|
caption: caption, subcaption: subcaption,
|
|
6
6
|
showNames: '1',
|
|
7
7
|
showValues:
|
|
8
|
-
@result[:rows].size > 15 || @result[:rows][0] && @result[:rows][0][:rows].size > 4 ? 0 : 1,
|
|
8
|
+
@result[:rows].size > 15 || (@result[:rows][0] && @result[:rows][0][:rows].size > 4) ? 0 : 1,
|
|
9
9
|
decimals: '0',
|
|
10
10
|
numberPrefix: '', clustered: '0', exeTime: '1.5', showPlotBorder: '0', zGapPlot: '30',
|
|
11
11
|
zDepth: '90', divLineEffect: 'emboss', startAngX: '10', endAngX: '18', startAngY: '-10',
|
|
@@ -11,7 +11,7 @@ def excel_summary_row_xlsx(sheet, result, parent_result = nil, dimension = 0, he
|
|
|
11
11
|
else
|
|
12
12
|
headers + [{
|
|
13
13
|
value: result[:value],
|
|
14
|
-
display_row_count: result[:nodes] + result[:row_count] * (@search.list ? 1 : 0)
|
|
14
|
+
display_row_count: result[:nodes] + (result[:row_count] * (@search.list ? 1 : 0))
|
|
15
15
|
}]
|
|
16
16
|
end
|
|
17
17
|
else
|
|
@@ -36,9 +36,7 @@ module SimpleDrilldown
|
|
|
36
36
|
# No default target class found
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
base.c_base_condition = "#{base.c_target_class.table_name}.deleted_at IS NULL"
|
|
39
|
+
base.update_base_condition
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def base_condition(base_condition)
|
|
@@ -63,6 +61,7 @@ module SimpleDrilldown
|
|
|
63
61
|
|
|
64
62
|
def target_class(target_class)
|
|
65
63
|
self.c_target_class = target_class
|
|
64
|
+
update_base_condition
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
def select(select)
|
|
@@ -148,25 +147,18 @@ module SimpleDrilldown
|
|
|
148
147
|
|
|
149
148
|
def legal_values_for(field, preserve_filter = false)
|
|
150
149
|
lambda do |search|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
filter_conditions, _t, includes = make_conditions(
|
|
150
|
+
filter = search.filter.dup
|
|
151
|
+
filter.delete(field.to_s) unless preserve_filter
|
|
152
|
+
filter_conditions, _t, includes = make_conditions(filter)
|
|
154
153
|
dimension_def = c_dimension_defs[field.to_s]
|
|
155
154
|
result_sets = dimension_def[:queries].map do |query|
|
|
156
|
-
if query[:includes]
|
|
157
|
-
if query[:includes].is_a?(Array)
|
|
158
|
-
includes += query[:includes]
|
|
159
|
-
else
|
|
160
|
-
includes << query[:includes]
|
|
161
|
-
end
|
|
162
|
-
includes.uniq!
|
|
163
|
-
end
|
|
155
|
+
includes = merge_includes(includes, query[:includes]) if query[:includes]
|
|
164
156
|
rows_query = c_target_class.unscoped.where(c_base_condition)
|
|
165
157
|
.select("#{query[:select]} AS value")
|
|
166
158
|
.joins(make_join([], c_target_class.name.underscore.to_sym, includes))
|
|
167
159
|
.order('value')
|
|
168
160
|
.group(:value)
|
|
169
|
-
|
|
161
|
+
rows_query = rows_query.without_deleted if c_target_class.try :paranoid?
|
|
170
162
|
rows_query = rows_query.where(filter_conditions) if filter_conditions
|
|
171
163
|
rows_query = rows_query.where(query[:where]) if query[:where]
|
|
172
164
|
rows = rows_query.to_a
|
|
@@ -301,6 +293,51 @@ module SimpleDrilldown
|
|
|
301
293
|
raise "Unknown join class: #{include.inspect}"
|
|
302
294
|
end
|
|
303
295
|
end
|
|
296
|
+
|
|
297
|
+
def merge_includes(*args)
|
|
298
|
+
hash = hash_includes(*args)
|
|
299
|
+
result = hash.dup.map do |k, v|
|
|
300
|
+
if v.blank?
|
|
301
|
+
hash.delete(k)
|
|
302
|
+
k
|
|
303
|
+
end
|
|
304
|
+
end.compact
|
|
305
|
+
result << hash unless hash.blank?
|
|
306
|
+
case result.size
|
|
307
|
+
when 0
|
|
308
|
+
nil
|
|
309
|
+
when 1
|
|
310
|
+
result[0]
|
|
311
|
+
else
|
|
312
|
+
result
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def hash_includes(*args)
|
|
317
|
+
args.inject({}) do |h, inc|
|
|
318
|
+
case inc
|
|
319
|
+
when Array
|
|
320
|
+
inc.each do |v|
|
|
321
|
+
h = hash_includes(h, v)
|
|
322
|
+
end
|
|
323
|
+
when Hash
|
|
324
|
+
inc.each do |k, v|
|
|
325
|
+
h[k] = merge_includes(h[k], v)
|
|
326
|
+
end
|
|
327
|
+
when NilClass, FalseClass
|
|
328
|
+
# Leave as it is
|
|
329
|
+
when String, Symbol
|
|
330
|
+
h[inc] ||= []
|
|
331
|
+
else
|
|
332
|
+
raise "Unknown include type: #{inc.inspect}"
|
|
333
|
+
end
|
|
334
|
+
h
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def update_base_condition
|
|
339
|
+
self.c_base_condition = "#{c_target_class.table_name}.deleted_at IS NULL" if c_target_class.try :paranoid?
|
|
340
|
+
end
|
|
304
341
|
end
|
|
305
342
|
|
|
306
343
|
def initialize
|
|
@@ -535,7 +572,7 @@ module SimpleDrilldown
|
|
|
535
572
|
def populate_list(conditions, includes, result, values)
|
|
536
573
|
return result[:rows].each { |r| populate_list(conditions, includes, r, values + [r[:value]]) } if result[:rows]
|
|
537
574
|
|
|
538
|
-
list_includes = merge_includes(includes, c_list_includes)
|
|
575
|
+
list_includes = self.class.merge_includes(includes, c_list_includes)
|
|
539
576
|
@search.fields.each do |field|
|
|
540
577
|
field_def = c_fields[field.to_sym]
|
|
541
578
|
raise "Field definition missing for: #{field.inspect}" unless field_def
|
|
@@ -557,47 +594,6 @@ module SimpleDrilldown
|
|
|
557
594
|
result[:records] = base_query.to_a
|
|
558
595
|
end
|
|
559
596
|
|
|
560
|
-
def merge_includes(*args)
|
|
561
|
-
hash = hash_includes(*args)
|
|
562
|
-
result = hash.dup.map do |k, v|
|
|
563
|
-
if v.blank?
|
|
564
|
-
hash.delete(k)
|
|
565
|
-
k
|
|
566
|
-
end
|
|
567
|
-
end.compact
|
|
568
|
-
result << hash unless hash.blank?
|
|
569
|
-
case result.size
|
|
570
|
-
when 0
|
|
571
|
-
nil
|
|
572
|
-
when 1
|
|
573
|
-
result[0]
|
|
574
|
-
else
|
|
575
|
-
result
|
|
576
|
-
end
|
|
577
|
-
end
|
|
578
|
-
|
|
579
|
-
def hash_includes(*args)
|
|
580
|
-
args.inject({}) do |h, inc|
|
|
581
|
-
case inc
|
|
582
|
-
when Array
|
|
583
|
-
inc.each do |v|
|
|
584
|
-
h = hash_includes(h, v)
|
|
585
|
-
end
|
|
586
|
-
when Hash
|
|
587
|
-
inc.each do |k, v|
|
|
588
|
-
h[k] = merge_includes(h[k], v)
|
|
589
|
-
end
|
|
590
|
-
when NilClass, FalseClass
|
|
591
|
-
# Leave as it is
|
|
592
|
-
when String, Symbol
|
|
593
|
-
h[inc] ||= []
|
|
594
|
-
else
|
|
595
|
-
raise "Unknown include type: #{inc.inspect}"
|
|
596
|
-
end
|
|
597
|
-
h
|
|
598
|
-
end
|
|
599
|
-
end
|
|
600
|
-
|
|
601
597
|
def list_conditions(conditions, values)
|
|
602
598
|
conditions ||= ['']
|
|
603
599
|
|
|
@@ -31,7 +31,7 @@ module SimpleDrilldown
|
|
|
31
31
|
if result[:rows]
|
|
32
32
|
sub_headers = headers + [{
|
|
33
33
|
value: result[:value],
|
|
34
|
-
display_row_count: result[:nodes] + result[:row_count] * (@search.list ? 1 : 0)
|
|
34
|
+
display_row_count: result[:nodes] + (result[:row_count] * (@search.list ? 1 : 0))
|
|
35
35
|
}]
|
|
36
36
|
significant_rows = result[:rows].reject { |r| r[:row_count].zero? }
|
|
37
37
|
significant_rows.each_with_index do |r, i|
|
|
@@ -62,7 +62,7 @@ module SimpleDrilldown
|
|
|
62
62
|
else
|
|
63
63
|
headers + [{
|
|
64
64
|
value: result[:value],
|
|
65
|
-
display_row_count: result[:nodes] + result[:row_count] * (@search.list ? 1 : 0)
|
|
65
|
+
display_row_count: result[:nodes] + (result[:row_count] * (@search.list ? 1 : 0))
|
|
66
66
|
}]
|
|
67
67
|
end
|
|
68
68
|
else
|
|
@@ -47,7 +47,7 @@ module SimpleDrilldown
|
|
|
47
47
|
attributes = attributes_or_search
|
|
48
48
|
@default_fields = default_fields
|
|
49
49
|
@default_select_value = default_select_value
|
|
50
|
-
@dimensions = attributes && attributes[:dimensions] || []
|
|
50
|
+
@dimensions = (attributes && attributes[:dimensions]) || []
|
|
51
51
|
@dimensions.delete_if(&:empty?)
|
|
52
52
|
@filter = attributes && attributes[:filter] ? attributes[:filter] : {}
|
|
53
53
|
@filter.keys.dup.each { |k| @filter[k] = Array(@filter[k]) }
|
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.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Uwe Kubosch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: caxlsx_rails
|
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
170
170
|
- !ruby/object:Gem::Version
|
|
171
171
|
version: '0'
|
|
172
172
|
requirements: []
|
|
173
|
-
rubygems_version: 3.2.
|
|
173
|
+
rubygems_version: 3.2.22
|
|
174
174
|
signing_key:
|
|
175
175
|
specification_version: 4
|
|
176
176
|
summary: Simple data warehouse and drilldown.
|