query_report 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{LICENSE.txt → MIT-LICENSE} +2 -4
- data/README.md +32 -53
- data/Rakefile +50 -0
- data/app/helpers/query_report_filter_helper.rb +22 -0
- data/app/helpers/query_report_helper.rb +31 -0
- data/app/views/query_report/_charts.html.erb +10 -0
- data/app/views/query_report/_search.html.erb +8 -0
- data/app/views/query_report/list.html.erb +19 -38
- data/config/locales/query_report.yml +7 -0
- data/config/routes.rb +2 -0
- data/db/schema.rb +34 -0
- data/lib/query_report.rb +22 -15
- data/lib/query_report/chart/chart_base.rb +60 -0
- data/lib/query_report/chart/chart_column.rb +12 -0
- data/lib/query_report/chart/column_chart.rb +40 -0
- data/lib/query_report/chart/pie_chart.rb +22 -25
- data/lib/query_report/chart/themes.rb +18 -114
- data/lib/query_report/column.rb +29 -18
- data/lib/query_report/config.rb +6 -0
- data/lib/query_report/engine.rb +4 -0
- data/lib/query_report/errors.rb +4 -0
- data/lib/query_report/filter.rb +110 -31
- data/lib/query_report/helper.rb +19 -3
- data/lib/query_report/paginate.rb +13 -0
- data/lib/query_report/record.rb +46 -0
- data/lib/query_report/report.rb +19 -102
- data/lib/query_report/report_pdf.rb +68 -84
- data/lib/query_report/version.rb +1 -1
- data/lib/tasks/query_report_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/invoices.js +2 -0
- data/test/dummy/app/assets/javascripts/users.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/invoices.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/users.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/invoices_controller.rb +114 -0
- data/test/dummy/app/controllers/users_controller.rb +91 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/invoices_helper.rb +2 -0
- data/test/dummy/app/helpers/users_helper.rb +2 -0
- data/test/dummy/app/models/invoice.rb +3 -0
- data/test/dummy/app/models/pdf_report_template.rb +24 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/views/invoices/_form.html.erb +33 -0
- data/test/dummy/app/views/invoices/edit.html.erb +6 -0
- data/test/dummy/app/views/invoices/index.html.erb +29 -0
- data/test/dummy/app/views/invoices/new.html.erb +5 -0
- data/test/dummy/app/views/invoices/show.html.erb +25 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/users/_form.html.erb +33 -0
- data/test/dummy/app/views/users/edit.html.erb +6 -0
- data/test/dummy/app/views/users/index.html.erb +29 -0
- data/test/dummy/app/views/users/new.html.erb +5 -0
- data/test/dummy/app/views/users/show.html.erb +25 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +60 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/query_report.rb +3 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +10 -0
- data/test/dummy/config/routes.rb +64 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130622120853_create_users.rb +12 -0
- data/test/dummy/db/migrate/20130630132513_create_invoices.rb +12 -0
- data/test/dummy/db/schema.rb +34 -0
- data/test/dummy/db/seed.rb +4 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +30613 -0
- data/test/dummy/log/test.log +28 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/invoices.yml +13 -0
- data/test/dummy/test/functional/invoices_controller_test.rb +49 -0
- data/test/dummy/test/unit/helpers/invoices_helper_test.rb +4 -0
- data/test/dummy/test/unit/invoice_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/CA9/F20/sprockets%2F00ff4f84806dd8834ab35f800a082640 +0 -0
- data/test/dummy/tmp/cache/assets/CAA/620/sprockets%2F87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/test/dummy/tmp/cache/assets/CB5/B70/sprockets%2Fa769d915e72b1c8c0614793b54d02c86 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/B70/sprockets%2F4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D46/650/sprockets%2Ff56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D54/B90/sprockets%2F90719d7bdca76469cd487928f710decb +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D67/B60/sprockets%2F5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/test/dummy/tmp/cache/assets/D7C/990/sprockets%2F302f7d851fcdb17936f8096bfb967cab +0 -0
- data/test/dummy/tmp/cache/assets/D7F/AF0/sprockets%2Fa7deca9af827ab462635389b96c7da39 +0 -0
- data/test/dummy/tmp/cache/assets/DA3/AC0/sprockets%2F797d3e5f21daaf5c046cc6ec4830e95b +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DFC/6F0/sprockets%2F2c45c36e4d7c7bfaeb826eeba29a09d2 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E0E/8A0/sprockets%2Fbecd48a9cf2ece858e433d7dcf0554f6 +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_5awpjfhldzcfjkeiia3p +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_a7ev5lal7xp2xzjj2n9p +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_c5lzifpf785aic4t3cm8 +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_etmdhvrbbmdadc7oyw8q +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_m0kxxiow6jlfcjulu02t +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_m2ow1xy7c6tw0f4fj2co +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_mitzsa7y0lvka04il6an +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_ujpdek4jfp8flbqp7fi3 +0 -0
- data/test/dummy/tmp/miniprofiler/mp_timers_wbiyljqrnox89js4m0at +0 -0
- data/test/dummy/tmp/miniprofiler/mp_views_127.0.0.1 +1 -0
- data/test/test_helper.rb +15 -0
- metadata +380 -24
- data/.gitignore +0 -18
- data/Gemfile +0 -10
- data/README.rdoc +0 -3
- data/app/views/query_report/_custom_filters.html.erb +0 -7
- data/lib/query_report/chart/basic_chart.rb +0 -41
- data/lib/query_report/chart/custom_chart.rb +0 -55
- data/lib/query_report/row.rb +0 -11
- data/query_report.gemspec +0 -31
data/.gitignore
DELETED
data/Gemfile
DELETED
data/README.rdoc
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<% if filter.type == :user %>
|
2
|
-
<% search_key = "#{filter.column.to_s}_id_eq"
|
3
|
-
user_id = @record.search.send(search_key)
|
4
|
-
user_name = User.find(user_id).name rescue '' %>
|
5
|
-
<%= user_search_field_tag "#{search_key}_search_field", user_name, :placeholder => filter.column.to_s.humanize, :'sync-id' => "q_#{search_key}" %>
|
6
|
-
<%= f.hidden_field search_key %>
|
7
|
-
<% end %>
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module QueryReport
|
2
|
-
module Chart
|
3
|
-
class BasicChart
|
4
|
-
attr_reader :title, :columns, :type, :data, :options
|
5
|
-
|
6
|
-
def initialize(type, name, columns, data, options={})
|
7
|
-
@type = type
|
8
|
-
@name = name
|
9
|
-
@columns = []
|
10
|
-
columns.each_with_index do |column, i|
|
11
|
-
@columns << QueryReport::Column.new(column, {type: (i == 0 ? 'string' : 'number')})
|
12
|
-
end
|
13
|
-
@data = data
|
14
|
-
@options = options
|
15
|
-
end
|
16
|
-
|
17
|
-
def prepare
|
18
|
-
data_table = GoogleVisualr::DataTable.new
|
19
|
-
columns.each do |column|
|
20
|
-
data_table.new_column(column.type, column.name)
|
21
|
-
end
|
22
|
-
|
23
|
-
rows = []
|
24
|
-
@data.each do |record|
|
25
|
-
row = []
|
26
|
-
columns.each do |column|
|
27
|
-
row << record[column.name]
|
28
|
-
end
|
29
|
-
rows << row
|
30
|
-
end
|
31
|
-
data_table.add_rows(rows)
|
32
|
-
|
33
|
-
opts = {:width => 400, :height => 240, :title => title, :hAxis => {:title => columns[0].name}}.merge(options)
|
34
|
-
|
35
|
-
chart_type = "#{type}_chart".classify
|
36
|
-
chart_type = "GoogleVisualr::Interactive::#{chart_type}".constantize
|
37
|
-
chart_type.new(data_table, opts)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'query_report/row'
|
2
|
-
require 'query_report/chart/themes'
|
3
|
-
|
4
|
-
module QueryReport
|
5
|
-
module Chart
|
6
|
-
class CustomChart
|
7
|
-
attr_reader :title, :type, :options, :data_table, :row, :rows
|
8
|
-
|
9
|
-
def initialize(type, title, query, options={})
|
10
|
-
@type = type
|
11
|
-
@title = title
|
12
|
-
@query = query
|
13
|
-
@options = options
|
14
|
-
@row = []
|
15
|
-
@rows = []
|
16
|
-
@data_table = GoogleVisualr::DataTable.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_column(title)
|
20
|
-
@data_table.new_column('string', title)
|
21
|
-
@row << title.humanize
|
22
|
-
end
|
23
|
-
|
24
|
-
def add(column_title, &block)
|
25
|
-
val = block.call(@query)
|
26
|
-
@data_table.new_column(val.kind_of?(String) ? 'string' : 'number', column_title)
|
27
|
-
@row << val
|
28
|
-
@rows << Row.new(column_title, val)
|
29
|
-
end
|
30
|
-
|
31
|
-
def prepare
|
32
|
-
@data_table.add_row(@row)
|
33
|
-
opts = {:width => 500, :height => 240, :title => @title, backgroundColor: 'transparent'}.merge(options)
|
34
|
-
chart_type = "#{type}_chart".classify
|
35
|
-
chart_type = "GoogleVisualr::Interactive::#{chart_type}".constantize
|
36
|
-
chart_type.new(@data_table, opts)
|
37
|
-
end
|
38
|
-
|
39
|
-
def prepare_gruff
|
40
|
-
@gruff = Gruff::Bar.new(options[:width] || 600)
|
41
|
-
@gruff.title = title
|
42
|
-
@gruff.theme = Gruff::Themes::GOOGLE_CHART
|
43
|
-
@rows.each do |row|
|
44
|
-
@gruff.data(row.name.humanize, row.value)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_blob
|
49
|
-
prepare_gruff
|
50
|
-
@gruff.to_blob
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/query_report/row.rb
DELETED
data/query_report.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'query_report/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "query_report"
|
8
|
-
gem.version = QueryReport::VERSION
|
9
|
-
gem.authors = ["A.K.M. Ashrafuzzaman"]
|
10
|
-
gem.email = ["ashrafuzzaman.g2@gmail.com"]
|
11
|
-
gem.description = %q{This is a gem to help you to structure common reports of you application just by writing in the controller}
|
12
|
-
gem.summary = %q{Structure you reports}
|
13
|
-
gem.homepage = "https://github.com/ashrafuzzaman/query_report"
|
14
|
-
|
15
|
-
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib", "app"]
|
19
|
-
|
20
|
-
gem.add_dependency "rails", "~> 3.2.13"
|
21
|
-
gem.add_dependency 'ransack'
|
22
|
-
gem.add_dependency 'google_visualr', '>= 2.1'
|
23
|
-
gem.add_dependency 'rmagick'
|
24
|
-
gem.add_dependency 'gruff'
|
25
|
-
gem.add_dependency 'kaminari'
|
26
|
-
|
27
|
-
gem.add_development_dependency "sqlite3"
|
28
|
-
gem.add_development_dependency "jquery-rails"
|
29
|
-
gem.add_development_dependency "bullet"
|
30
|
-
gem.add_development_dependency "rack-mini-profiler"
|
31
|
-
end
|