simple_drilldown 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = simple_drilldown
2
-
3
- An analysis framework for active record.
4
-
5
- == Contributing to simple_drilldown
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 donv. See LICENSE.txt for
18
- further details.
19
-
@@ -1,95 +0,0 @@
1
- class SampleDrilldownController < DrilldownController
2
-
3
- default_fields %w{time receipt operation flight aircraft_registration stand volume_abbr volume_compensated payment_type supplier}
4
- target_class Transaction
5
- select "sum(CASE WHEN operation = 'FUELLING' THEN #{Volume::Sql::VOLUME} ELSE -#{Volume::Sql::VOLUME} END) as volume, sum(CASE WHEN operation = 'FUELLING' THEN #{Volume::Sql::VOLUME_COMPENSATED} ELSE -#{Volume::Sql::VOLUME_COMPENSATED} END) as volume_compensated, sum(CASE WHEN operation = 'CREDIT' THEN -1 ELSE 1 END) as count".freeze
6
- list_includes :operator, :stand, :supplier, :vehicle
7
- list_order 'transactions.created_at'
8
-
9
- field :aircraft_registration, :last_change_time => true
10
- field :aircraft_subtype, :attr_method => lambda { |transaction| transaction.aircraft_subtype_code }
11
- field :airfield_fee => {:excel_type => 'Number', :excel_style => 'ThreeDecimalNumberFormat'},
12
- field :authorization_reference => { :attr_method => lambda { |transaction| transaction.authorization.try(:authorization_reference) }},
13
- field :carnet_no => {},
14
- field :cash_price => {:excel_type => 'Number', :excel_style => 'ThreeDecimalNumberFormat'},
15
- field :co2_fee => {:excel_type => 'Number', :excel_style => 'ThreeDecimalNumberFormat'},
16
- field :comment => {},
17
- # :customer_name => {},
18
- # :defuelling_fee => {:excel_type => 'Number',
19
- # :excel_style => 'ThreeDecimalNumberFormat'},
20
- # :delay_codes => {},
21
- # :density => {:excel_type => 'Number',
22
- # :excel_style => 'StandardNumberFormat'},
23
- # :destination => {},
24
- # :dispatched => { :attr_method => lambda { |t| t.assignment.try(:created_at).try(:localtime).try(:strftime, '%H:%M') } },
25
- # :external => { :attr_method => lambda { |transaction| transaction.external_flight }},
26
- # :flight =>{ :attr_method => lambda { |transaction| transaction.flight_no } },
27
- # :fuel_request => { :attr_method => lambda { |t| t.assignment.try(:fuel_request)}, :last_change_time => true, :include => {:assignment => :order}},
28
- # :invoice_code => { :attr_method => lambda { |transaction| transaction.contract.try(:invoice_code)}},
29
- # :ofb => { :attr_method => lambda { |t| t.assignment.try(:order).try(:ofb).try(:localtime).try(:strftime, '%H:%M') } },
30
- # :onb => { :attr_method => lambda { |t| t.assignment.try(:order).try(:onb).try(:localtime).try(:strftime, '%H:%M') } },
31
- # :operation => {},
32
- # :operator_abbr => { :attr_method => lambda { |transaction| transaction.operator.try(:login) } },
33
- # :payment_type => {},
34
- # :product => {},
35
- # :ptd => { :attr_method =>lambda { |transaction| transaction.assignment.try(:order).try(:ptd).try(:localtime).try(:strftime, '%H:%M') } },
36
- # :receipt => { :attr_method => lambda { |transaction| transaction.receipt_code } },
37
- # # Not paid for, yet.
38
- # # :receptacle => {},
39
- # :receptacle_fee => {:excel_type => 'Number',
40
- # :excel_style => 'ThreeDecimalNumberFormat'},
41
- # :remarks => { :attr_method => lambda { |t| t.assignment.try(:order).try(:remarks) } },
42
- # :remote_fee => { :attr_method => lambda { |transaction| transaction.remote_fuelling_fee },
43
- # :excel_type => 'Number',
44
- # :excel_style => 'ThreeDecimalNumberFormat'},
45
- # :sta => { :attr_method =>lambda { |t| t.assignment.try(:order).try(:sta).try(:localtime).try(:strftime, '%H:%M') } },
46
- # :stand => { :attr_method =>lambda { |transaction| transaction.stand.try(:code) } },
47
- # :started => { :attr_method =>lambda { |t| t.assignment.try(:started_at).try(:localtime).try(:strftime, '%H:%M') } },
48
- # :std => { :attr_method =>lambda { |transaction| transaction.assignment.try(:order).try(:std).try(:localtime).try(:strftime, '%H:%M') } },
49
- # :supplier => { :attr_method => lambda { |transaction| transaction.supplier.try(:name) }},
50
- # :supplier_price => {:excel_type => 'Number',
51
- # :excel_style => 'ThreeDecimalNumberFormat'},
52
- # :temperature => {:excel_type => 'Number',
53
- # :excel_style => 'StandardNumberFormat'},
54
- # :time => {},
55
- # :vat_factor => {:excel_type => 'Number',
56
- # :excel_style => 'ThreeDecimalNumberFormat'},
57
- # :vehicle => { :attr_method => lambda { |transaction| transaction.vehicle.try(:name) }},
58
- # :volume_abbr => { :attr_method => lambda { |transaction| transaction.volume },
59
- # :excel_type => 'Number' },
60
- # :volume_compensated => {:excel_type => 'Number'},
61
- # :zero_fuelling_fee => {:excel_type => 'Number',
62
- # :excel_style => 'ThreeDecimalNumberFormat'},
63
- # }
64
-
65
- dimension :calendar_date, "DATE(transactions.created_at AT TIME ZONE 'CET0')", :interval => true
66
- dimension :comment, "CASE WHEN (transactions.comment is not null AND transactions.comment <> '') THEN 'Yes' ELSE 'No' END"
67
- dimension :corrected, "CASE WHEN meter1_start_volume_manual is not null OR meter1_stop_volume_manual is not null OR meter2_start_volume_manual is not null OR meter2_stop_volume_manual is not null THEN 'Yes' ELSE 'No' END"
68
- dimension :customer, 'COALESCE(customers.name, customer_name)', :includes => {:contract => :customer}
69
- dimension :day_of_month, "date_part('day', transactions.created_at AT TIME ZONE 'CET0')"
70
- dimension :day_of_week, "CASE WHEN date_part('dow', transactions.created_at AT TIME ZONE 'CET0') = 0 THEN 7 ELSE date_part('dow', transactions.created_at AT TIME ZONE 'CET0') END",
71
- :label_method => lambda { |day_no| Date::DAYNAMES[day_no.to_i % 7] }
72
- dimension :delay_codes, "transactions.delay_codes IS NOT NULL AND (transactions.delay_codes LIKE '%GF36%')",
73
- :label_method => lambda { |val| val == 't' || val == 'true' ? 'With' : 'Without' },
74
- :legal_values => lambda { | val | [['With', 't'], ['Without', 'f']]}
75
- dimension :destination, "CASE WHEN external_flight = 't' THEN '#{t(:international)}' ELSE '#{t(:domestic)}' END"
76
- dimension :hour_of_day, "date_part('hour', transactions.created_at AT TIME ZONE 'CET0')"
77
- dimension :manual, "CASE WHEN receipt_no < #{Transactional::MANUAL_RECEIPT_NO_LIMIT} THEN 'Automatic' ELSE 'Manual' END"
78
- dimension :month, "date_part('month', transactions.created_at AT TIME ZONE 'CET0')",
79
- :label_method => lambda { |month_no| Date::MONTHNAMES[month_no.to_i] }
80
- dimension :operation, 'operation'
81
- dimension :operator, 'users.login', :includes => :operator
82
- dimension :payment_type, 'payment_type'
83
- dimension :pit, 'pits.code', :includes => :pit
84
- # Not paid for yet: 4h
85
- # dimension :receptacle, 'receptacle'
86
- dimension :stand, 'stands.code', :includes => :stand
87
- dimension :supplier, 'suppliers.name', :includes => :supplier
88
- dimension :terminal, "CASE WHEN stands.code like '3__%' THEN 'GA' WHEN stands.code like 'M%' THEN 'Military' WHEN stands.code like 'PAD' THEN 'PAD' ELSE 'Terminal 1' END",
89
- :includes => :stand, :label_method => lambda { |val| val }
90
- dimension :vehicle, 'vehicles.name', :includes => :vehicle
91
- dimension :week, "date_part('week', transactions.created_at AT TIME ZONE 'CET0')"
92
- dimension :year, "date_part('year', transactions.created_at AT TIME ZONE 'CET0')"
93
- dimension :zero_fuelling, "CASE WHEN zero_fuelling_fee is not null THEN 'Zero' ELSE 'Non-zero' END"
94
-
95
- end
@@ -1,66 +0,0 @@
1
- module TransactionDrillownHelper
2
- def value_label(dimension_index, value)
3
- return nil if @dimensions[dimension_index].nil?
4
- h(@dimensions[dimension_index][:label_method] ?
5
- @dimensions[dimension_index][:label_method].call(value) :
6
- value)
7
- end
8
-
9
- def caption
10
- result = @search.title ? @search.title : "Transaction #{l(@search.select_value.downcase)}" + (@dimensions && @dimensions[0] && @dimensions[0][:pretty_name] ? " by #{@dimensions[0][:pretty_name]}" : "")
11
- result.gsub('$date', [*@search.filter[:calendar_date]].uniq.join(' - '))
12
- end
13
-
14
- def subcaption
15
- @search.title ? '' : @filter_text && @filter_text.size > 0 ? "for #{@filter_text}" : ""
16
- end
17
-
18
- def summary_row(result, dimension = 0, headers = [], new_row = true)
19
- html = render(:partial => '/transaction_drilldown/summary_row', :locals => {:result => result, :new_row => new_row, :dimension => dimension, :headers => headers, :with_results => !result[:rows]})
20
- if result[:rows]
21
- sub_headers = headers + [{:value => result[:value], :display_row_count => result[:nodes] + result[:row_count] * (@search.list ? 1 : 0)}]
22
- significant_rows = result[:rows].select{|r| r[:row_count] != 0}
23
- significant_rows.each_with_index do |r, i|
24
- html << summary_row(r, dimension + 1, sub_headers, i > 0)
25
- end
26
- elsif @search.list
27
- html << render(:partial => '/transaction_drilldown/transaction_list', :locals => {:result => result})
28
- end
29
- if dimension < @dimensions.size
30
- html << render(:partial => '/transaction_drilldown/summary_total_row', :locals => {:result => result, :headers => headers.dup, :dimension => dimension})
31
- end
32
-
33
- return html
34
- end
35
-
36
- def excel_summary_row(result, dimension, headers)
37
- xml = ''
38
- if result[:rows]
39
- significant_rows = result[:rows].select{|r| r[:row_count] != 0}
40
- significant_rows.each_with_index do |r, i|
41
- if i == 0
42
- if dimension == 0
43
- sub_headers = headers
44
- else
45
- sub_headers = headers + [{:value => result[:value], :display_row_count => result[:nodes] + result[:row_count] * (@search.list ? 1 : 0)}]
46
- end
47
- else
48
- sub_headers = [] # [{:value => result[:value], :row_count => result[:row_count]}]
49
- end
50
- xml << excel_summary_row(r, dimension + 1, sub_headers)
51
- end
52
- else
53
- xml << render(:partial => '/transaction_drilldown/excel_summary_row', :locals => {:result => result, :headers => headers.dup, :dimension => dimension})
54
-
55
- if @search.list
56
- xml << render(:partial => '/transaction_drilldown/excel_transaction_list', :locals => {:result => result})
57
- end
58
- end
59
-
60
- if dimension < @dimensions.size
61
- xml << render(:partial => '/transaction_drilldown/excel_summary_total_row', :locals => {:result => result, :headers => headers.dup, :dimension => dimension})
62
- end
63
- xml
64
- end
65
-
66
- end
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'simple_drilldown/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'simple_drilldown'
8
- spec.version = SimpleDrilldown::VERSION
9
- spec.authors = ['Uwe Kubosch']
10
- spec.email = %w(uwe@kubosch.no)
11
- spec.summary = %q{Simple data warehouse and drilldown.}
12
- spec.description = %q{simple_drilldown offers a simple way to define axis to filter and group records for analysis.}
13
- spec.homepage = 'http://github.com/datekwireless/simple_drilldown'
14
- spec.license = 'MIT'
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = %w(lib)
20
-
21
- spec.add_dependency 'rails'
22
- spec.add_development_dependency 'bundler', '~> 1.3'
23
- spec.add_development_dependency 'rake'
24
- end
data/test/helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'simple_drilldown'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSimpleDrilldown < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end