simple_drilldown 0.0.3 → 0.1.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.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/{LICENSE.txt → MIT-LICENSE} +1 -3
  3. data/README.md +15 -16
  4. data/Rakefile +32 -0
  5. data/app/assets/config/simple_drilldown_manifest.js +1 -0
  6. data/app/assets/stylesheets/simple_drilldown/application.css +121 -0
  7. data/app/controllers/simple_drilldown/application_controller.rb +7 -0
  8. data/app/helpers/simple_drilldown/application_helper.rb +6 -0
  9. data/app/jobs/simple_drilldown/application_job.rb +6 -0
  10. data/app/mailers/simple_drilldown/application_mailer.rb +8 -0
  11. data/app/models/simple_drilldown/application_record.rb +7 -0
  12. data/app/views/drilldown/_chart.html.erb +57 -0
  13. data/app/views/drilldown/_excel_record_list.builder +7 -0
  14. data/app/views/drilldown/_excel_row.builder +24 -0
  15. data/app/views/drilldown/_excel_row_header.builder +10 -0
  16. data/app/views/drilldown/_excel_styles.builder +69 -0
  17. data/app/views/drilldown/_excel_summary_row.builder +16 -0
  18. data/app/views/drilldown/_excel_summary_total_row.builder +14 -0
  19. data/app/views/drilldown/_field.html.erb +39 -0
  20. data/app/views/drilldown/_fields.html.erb +12 -0
  21. data/app/views/drilldown/_filter.html.erb +20 -0
  22. data/app/views/drilldown/_record_list.html.erb +12 -0
  23. data/app/views/drilldown/_row.html.erb +13 -0
  24. data/app/views/drilldown/_row_header.html.erb +8 -0
  25. data/app/views/drilldown/_summary_row.html.erb +18 -0
  26. data/app/views/drilldown/_summary_table.html.erb +12 -0
  27. data/app/views/drilldown/_summary_total_row.html.erb +4 -0
  28. data/app/views/drilldown/_tab_buttons.html.erb +5 -0
  29. data/app/views/drilldown/data_0.builder +10 -0
  30. data/app/views/drilldown/data_1.builder +11 -0
  31. data/app/views/drilldown/data_2.builder +37 -0
  32. data/app/views/drilldown/data_3.builder +37 -0
  33. data/app/views/drilldown/excel_export.builder +42 -0
  34. data/app/views/drilldown/excel_export_transactions.builder +90 -0
  35. data/app/views/drilldown/html_export.html.erb +6 -0
  36. data/app/views/drilldown/index.html.erb +107 -0
  37. data/app/views/drilldown/print.html.erb +18 -0
  38. data/app/views/layouts/simple_drilldown/application.html.erb +15 -0
  39. data/config/locales/en.yml +23 -0
  40. data/config/locales/nb.yml +20 -0
  41. data/config/routes.rb +4 -0
  42. data/lib/generators/drilldown_controller/USAGE +8 -0
  43. data/lib/generators/drilldown_controller/drilldown_controller_generator.rb +8 -0
  44. data/lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb +41 -0
  45. data/lib/simple_drilldown.rb +3 -3
  46. data/lib/simple_drilldown/drilldown_controller.rb +389 -274
  47. data/lib/simple_drilldown/drilldown_helper.rb +68 -0
  48. data/lib/simple_drilldown/engine.rb +11 -0
  49. data/lib/simple_drilldown/search.rb +12 -1
  50. data/lib/simple_drilldown/version.rb +1 -1
  51. data/lib/tasks/simple_drilldown_tasks.rake +5 -0
  52. metadata +85 -34
  53. data/.document +0 -5
  54. data/.gitignore +0 -22
  55. data/Gemfile +0 -3
  56. data/Gemfile.lock +0 -89
  57. data/README.rdoc +0 -19
  58. data/lib/sample_drilldown_controller.rb +0 -95
  59. data/lib/simple_drilldown/simple_drilldown_helper.rb +0 -66
  60. data/simple_drilldown.gemspec +0 -24
  61. data/test/helper.rb +0 -18
  62. data/test/test_simple_drilldown.rb +0 -7
@@ -0,0 +1,68 @@
1
+ module SimpleDrilldown
2
+ module DrilldownHelper
3
+ def value_label(dimension_index, value)
4
+ return nil if @dimensions[dimension_index].nil?
5
+ h(@dimensions[dimension_index][:label_method] ?
6
+ @dimensions[dimension_index][:label_method].call(value) :
7
+ value)
8
+ end
9
+
10
+ def caption
11
+ result = @search.title ? @search.title : "#{@target_class} #{t(@search.select_value.downcase)}" +
12
+ ((@dimensions && @dimensions.any?) ? ' by ' + @dimensions.map { |d| d[:pretty_name] }.join(' and ') : '')
13
+ result.gsub('$date', [*@search.filter[:calendar_date]].uniq.join(' - '))
14
+ end
15
+
16
+ def subcaption
17
+ @search.title ? '' : @filter_text && @filter_text.size > 0 ? "for #{@filter_text}" : ''
18
+ end
19
+
20
+ def summary_row(result, parent_result = nil, dimension = 0, headers = [], new_row = true)
21
+ html = render(:partial => '/drilldown/summary_row', :locals => { :result => result, :parent_result => parent_result, :new_row => new_row, :dimension => dimension, :headers => headers, :with_results => !result[:rows] })
22
+ if result[:rows]
23
+ sub_headers = headers + [{ :value => result[:value], :display_row_count => result[:nodes] + result[:row_count] * (@search.list ? 1 : 0) }]
24
+ significant_rows = result[:rows].select { |r| r[:row_count] != 0 }
25
+ significant_rows.each_with_index do |r, i|
26
+ html << summary_row(r, result, dimension + 1, sub_headers, i > 0)
27
+ end
28
+ elsif @search.list
29
+ html << render(:partial => '/drilldown/record_list', :locals => { :result => result })
30
+ end
31
+ if dimension < @dimensions.size
32
+ html << render(:partial => '/drilldown/summary_total_row', :locals => { :result => result, :parent_result => parent_result, :headers => headers.dup, :dimension => dimension })
33
+ end
34
+
35
+ html
36
+ end
37
+
38
+ def excel_summary_row(result, parent_result = nil, dimension = 0, headers = [])
39
+ xml = ''
40
+ if result[:rows]
41
+ significant_rows = result[:rows].select { |r| r[:row_count] != 0 }
42
+ significant_rows.each_with_index do |r, i|
43
+ if i == 0
44
+ if dimension == 0
45
+ sub_headers = headers
46
+ else
47
+ sub_headers = headers + [{ :value => result[:value], :display_row_count => result[:nodes] + result[:row_count] * (@search.list ? 1 : 0) }]
48
+ end
49
+ else
50
+ sub_headers = [] # [{:value => result[:value], :row_count => result[:row_count]}]
51
+ end
52
+ xml << excel_summary_row(r, result, dimension + 1, sub_headers)
53
+ end
54
+ else
55
+ xml << render(:partial => '/drilldown/excel_summary_row', :locals => { :result => result, :parent_result => parent_result, :headers => headers.dup, :dimension => dimension })
56
+
57
+ if @search.list
58
+ xml << render(:partial => '/drilldown/excel_record_list', :locals => { :result => result })
59
+ end
60
+ end
61
+
62
+ if dimension < @dimensions.size
63
+ xml << render(:partial => '/drilldown/excel_summary_total_row', :locals => { :result => result, :headers => headers.dup, :dimension => dimension })
64
+ end
65
+ xml
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace SimpleDrilldown
6
+
7
+ initializer "simple_drilldown.assets.precompile" do |app|
8
+ app.config.assets.precompile += %w( chartkick.js )
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,9 @@
1
+ require 'active_model/naming'
2
+
1
3
  module SimpleDrilldown
2
4
  class Search
5
+ extend ActiveModel::Naming
6
+
3
7
  module DisplayType
4
8
  BAR = 'BAR'
5
9
  LINE = 'LINE'
@@ -17,13 +21,14 @@ module SimpleDrilldown
17
21
  attr_reader :fields
18
22
  attr_reader :filter
19
23
  attr_accessor :list
24
+ attr_accessor :percent
20
25
  attr_reader :last_change_time
21
26
  attr_reader :order_by_value
22
27
  attr_reader :select_value
23
28
  attr_reader :title
24
29
  attr_reader :default_fields
25
30
 
26
- def initialize(attributes_or_search, default_fields = nil)
31
+ def initialize(attributes_or_search, default_fields = nil, default_select_value = nil)
27
32
  if attributes_or_search.is_a? Search
28
33
  s = attributes_or_search
29
34
  @dimensions = s.dimensions.dup
@@ -31,6 +36,7 @@ module SimpleDrilldown
31
36
  @fields = s.fields.dup
32
37
  @filter = s.filter.dup
33
38
  @list = s.list
39
+ @percent = s.percent
34
40
  @last_change_time = s.last_change_time
35
41
  @order_by_value = s.order_by_value
36
42
  @select_value = s.select_value.dup
@@ -52,6 +58,7 @@ module SimpleDrilldown
52
58
  @order_by_value = attributes && (attributes[:order_by_value] == '1')
53
59
  @select_value = attributes && attributes[:select_value] && attributes[:select_value].size > 0 ? attributes[:select_value] : SelectValue::COUNT
54
60
  @list = attributes && attributes[:list] && attributes[:list] == '1' || false
61
+ @percent = attributes&.[](:percent) == '1'
55
62
  @last_change_time = attributes && attributes[:last_change_time] && attributes[:last_change_time] == '1' || false
56
63
  if (attributes && attributes[:fields])
57
64
  if attributes[:fields].is_a?(Array)
@@ -73,6 +80,7 @@ module SimpleDrilldown
73
80
  :list => list ? '1' : '0',
74
81
  :last_change_time => last_change_time ? '1' : '0',
75
82
  :filter => filter,
83
+ percent: percent ? '1' : '0',
76
84
  :dimensions => dimensions,
77
85
  :display_type => display_type,
78
86
  }
@@ -94,5 +102,8 @@ module SimpleDrilldown
94
102
  s
95
103
  end
96
104
 
105
+ def to_key
106
+ url_options.to_a
107
+ end
97
108
  end
98
109
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleDrilldown
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # desc "Explaining what the task does"
3
+ # task :simple_drilldown do
4
+ # # Task goes here
5
+ # end
metadata CHANGED
@@ -1,106 +1,157 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_drilldown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.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: 2013-07-21 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: chartkick
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.3'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.3'
27
47
  - !ruby/object:Gem::Dependency
28
- name: bundler
48
+ name: rubocop
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
- - - ~>
51
+ - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '1.3'
53
+ version: '0.80'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
- - - ~>
58
+ - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '1.3'
60
+ version: '0.80'
41
61
  - !ruby/object:Gem::Dependency
42
- name: rake
62
+ name: sqlite3
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
45
- - - '>='
65
+ - - ">="
46
66
  - !ruby/object:Gem::Version
47
67
  version: '0'
48
68
  type: :development
49
69
  prerelease: false
50
70
  version_requirements: !ruby/object:Gem::Requirement
51
71
  requirements:
52
- - - '>='
72
+ - - ">="
53
73
  - !ruby/object:Gem::Version
54
74
  version: '0'
55
75
  description: simple_drilldown offers a simple way to define axis to filter and group
56
76
  records for analysis.
57
77
  email:
58
- - uwe@kubosch.no
78
+ - uwe@datek.no
59
79
  executables: []
60
80
  extensions: []
61
81
  extra_rdoc_files: []
62
82
  files:
63
- - .document
64
- - .gitignore
65
- - Gemfile
66
- - Gemfile.lock
67
- - LICENSE.txt
83
+ - MIT-LICENSE
68
84
  - README.md
69
- - README.rdoc
70
85
  - Rakefile
71
- - lib/sample_drilldown_controller.rb
86
+ - app/assets/config/simple_drilldown_manifest.js
87
+ - app/assets/stylesheets/simple_drilldown/application.css
88
+ - app/controllers/simple_drilldown/application_controller.rb
89
+ - app/helpers/simple_drilldown/application_helper.rb
90
+ - app/jobs/simple_drilldown/application_job.rb
91
+ - app/mailers/simple_drilldown/application_mailer.rb
92
+ - app/models/simple_drilldown/application_record.rb
93
+ - app/views/drilldown/_chart.html.erb
94
+ - app/views/drilldown/_excel_record_list.builder
95
+ - app/views/drilldown/_excel_row.builder
96
+ - app/views/drilldown/_excel_row_header.builder
97
+ - app/views/drilldown/_excel_styles.builder
98
+ - app/views/drilldown/_excel_summary_row.builder
99
+ - app/views/drilldown/_excel_summary_total_row.builder
100
+ - app/views/drilldown/_field.html.erb
101
+ - app/views/drilldown/_fields.html.erb
102
+ - app/views/drilldown/_filter.html.erb
103
+ - app/views/drilldown/_record_list.html.erb
104
+ - app/views/drilldown/_row.html.erb
105
+ - app/views/drilldown/_row_header.html.erb
106
+ - app/views/drilldown/_summary_row.html.erb
107
+ - app/views/drilldown/_summary_table.html.erb
108
+ - app/views/drilldown/_summary_total_row.html.erb
109
+ - app/views/drilldown/_tab_buttons.html.erb
110
+ - app/views/drilldown/data_0.builder
111
+ - app/views/drilldown/data_1.builder
112
+ - app/views/drilldown/data_2.builder
113
+ - app/views/drilldown/data_3.builder
114
+ - app/views/drilldown/excel_export.builder
115
+ - app/views/drilldown/excel_export_transactions.builder
116
+ - app/views/drilldown/html_export.html.erb
117
+ - app/views/drilldown/index.html.erb
118
+ - app/views/drilldown/print.html.erb
119
+ - app/views/layouts/simple_drilldown/application.html.erb
120
+ - config/locales/en.yml
121
+ - config/locales/nb.yml
122
+ - config/routes.rb
123
+ - lib/generators/drilldown_controller/USAGE
124
+ - lib/generators/drilldown_controller/drilldown_controller_generator.rb
125
+ - lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb
72
126
  - lib/simple_drilldown.rb
73
127
  - lib/simple_drilldown/drilldown_controller.rb
128
+ - lib/simple_drilldown/drilldown_helper.rb
129
+ - lib/simple_drilldown/engine.rb
74
130
  - lib/simple_drilldown/search.rb
75
- - lib/simple_drilldown/simple_drilldown_helper.rb
76
131
  - lib/simple_drilldown/version.rb
77
- - simple_drilldown.gemspec
78
- - test/helper.rb
79
- - test/test_simple_drilldown.rb
132
+ - lib/tasks/simple_drilldown_tasks.rake
80
133
  homepage: http://github.com/datekwireless/simple_drilldown
81
134
  licenses:
82
135
  - MIT
83
- metadata: {}
136
+ metadata:
137
+ allowed_push_host: https://rubygems.org/
84
138
  post_install_message:
85
139
  rdoc_options: []
86
140
  require_paths:
87
141
  - lib
88
142
  required_ruby_version: !ruby/object:Gem::Requirement
89
143
  requirements:
90
- - - '>='
144
+ - - ">="
91
145
  - !ruby/object:Gem::Version
92
146
  version: '0'
93
147
  required_rubygems_version: !ruby/object:Gem::Requirement
94
148
  requirements:
95
- - - '>='
149
+ - - ">="
96
150
  - !ruby/object:Gem::Version
97
151
  version: '0'
98
152
  requirements: []
99
- rubyforge_project:
100
- rubygems_version: 2.0.3
153
+ rubygems_version: 3.0.3
101
154
  signing_key:
102
155
  specification_version: 4
103
156
  summary: Simple data warehouse and drilldown.
104
- test_files:
105
- - test/helper.rb
106
- - test/test_simple_drilldown.rb
157
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *~
2
- \#*
3
- .\#*
4
- *.gem
5
- *.rbc
6
- .bundle
7
- .config
8
- .DS_Store
9
- /.idea
10
- .yardoc
11
- _yardoc
12
- coverage
13
- doc/
14
- Gemfile.lock
15
- InstalledFiles
16
- lib/bundler/man
17
- pkg
18
- rdoc
19
- spec/reports
20
- test/tmp
21
- test/version_tmp
22
- tmp
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,89 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- simple_drilldown (0.0.2)
5
- rails
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actionmailer (4.0.0)
11
- actionpack (= 4.0.0)
12
- mail (~> 2.5.3)
13
- actionpack (4.0.0)
14
- activesupport (= 4.0.0)
15
- builder (~> 3.1.0)
16
- erubis (~> 2.7.0)
17
- rack (~> 1.5.2)
18
- rack-test (~> 0.6.2)
19
- activemodel (4.0.0)
20
- activesupport (= 4.0.0)
21
- builder (~> 3.1.0)
22
- activerecord (4.0.0)
23
- activemodel (= 4.0.0)
24
- activerecord-deprecated_finders (~> 1.0.2)
25
- activesupport (= 4.0.0)
26
- arel (~> 4.0.0)
27
- activerecord-deprecated_finders (1.0.3)
28
- activesupport (4.0.0)
29
- i18n (~> 0.6, >= 0.6.4)
30
- minitest (~> 4.2)
31
- multi_json (~> 1.3)
32
- thread_safe (~> 0.1)
33
- tzinfo (~> 0.3.37)
34
- arel (4.0.0)
35
- atomic (1.1.10-java)
36
- builder (3.1.4)
37
- erubis (2.7.0)
38
- hike (1.2.3)
39
- i18n (0.6.4)
40
- mail (2.5.4)
41
- mime-types (~> 1.16)
42
- treetop (~> 1.4.8)
43
- mime-types (1.23)
44
- minitest (4.7.5)
45
- multi_json (1.7.7)
46
- polyglot (0.3.3)
47
- rack (1.5.2)
48
- rack-test (0.6.2)
49
- rack (>= 1.0)
50
- rails (4.0.0)
51
- actionmailer (= 4.0.0)
52
- actionpack (= 4.0.0)
53
- activerecord (= 4.0.0)
54
- activesupport (= 4.0.0)
55
- bundler (>= 1.3.0, < 2.0)
56
- railties (= 4.0.0)
57
- sprockets-rails (~> 2.0.0)
58
- railties (4.0.0)
59
- actionpack (= 4.0.0)
60
- activesupport (= 4.0.0)
61
- rake (>= 0.8.7)
62
- thor (>= 0.18.1, < 2.0)
63
- rake (10.1.0)
64
- sprockets (2.10.0)
65
- hike (~> 1.2)
66
- multi_json (~> 1.0)
67
- rack (~> 1.0)
68
- tilt (~> 1.1, != 1.3.0)
69
- sprockets-rails (2.0.0)
70
- actionpack (>= 3.0)
71
- activesupport (>= 3.0)
72
- sprockets (~> 2.8)
73
- thor (0.18.1)
74
- thread_safe (0.1.0)
75
- atomic
76
- tilt (1.4.1)
77
- treetop (1.4.14)
78
- polyglot
79
- polyglot (>= 0.3.1)
80
- tzinfo (0.3.37)
81
-
82
- PLATFORMS
83
- java
84
- ruby
85
-
86
- DEPENDENCIES
87
- bundler (~> 1.3)
88
- rake
89
- simple_drilldown!