old_sql 0.50.0 → 0.51.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.
- data/app/controllers/old_sql/report_controller.rb +14 -42
- data/app/views/layouts/old_sql/report.html.erb +2 -0
- data/app/views/old_sql/report/datagrid.html.erb +3 -3
- data/app/views/old_sql/report/index.html.erb +1 -77
- data/config/old_sql/reports.yml.example +1 -1
- data/lib/generators/old_sql/templates/old_sql.rb +4 -1
- data/lib/old_sql/report_processor/base.rb +24 -5
- data/lib/old_sql.rb +4 -0
- data/public/javascripts/old_sql/old_sql.js +76 -0
- metadata +3 -2
@@ -24,6 +24,11 @@ module OldSql
|
|
24
24
|
@report_name = params[:report]
|
25
25
|
@report_sql = params[:report_sql]
|
26
26
|
|
27
|
+
#todo allow these to be overridden in the report config
|
28
|
+
@row_num = OldSql.jqgrid_row_num
|
29
|
+
@width = OldSql.jqgrid_width
|
30
|
+
@height = OldSql.jqgrid_height
|
31
|
+
|
27
32
|
render :template => "old_sql/report/datagrid.html.erb"
|
28
33
|
end
|
29
34
|
|
@@ -39,14 +44,9 @@ module OldSql
|
|
39
44
|
@report_sql << "_gen_#{@generation}"
|
40
45
|
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
logger.info "END_DATE: #{@end_date}"
|
46
|
-
logger.info "GENERATION: #{@generation}"
|
47
|
-
|
48
|
-
processor = load_processor(@report_name)
|
49
|
-
@report = processor.execute_query(@report_sql,@start_date,@end_date,query_vars(@report_name),@reports[@report_name]['report_design'])
|
47
|
+
processor = load_base_processor
|
48
|
+
@report = processor.execute_query(@report_sql,@start_date,@end_date,query_vars(@report_name),@reports[@report_name]['report_design'],
|
49
|
+
@reports[@report_name]['report_processor'])
|
50
50
|
|
51
51
|
respond_to do |format|
|
52
52
|
format.json { render :json => @report.to_json}
|
@@ -87,14 +87,9 @@ module OldSql
|
|
87
87
|
@report_sql << "_gen_#{@generation}"
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
logger.info "END_DATE: #{@end_date}"
|
94
|
-
logger.info "GENERATION: #{@generation}"
|
95
|
-
|
96
|
-
processor = load_processor(@report_name)
|
97
|
-
@report = processor.execute_query(@report_sql,@start_date,@end_date,query_vars(@report_name))
|
90
|
+
processor = load_base_processor
|
91
|
+
@report = processor.execute_query(@report_sql,@start_date,@end_date,query_vars(@report_name),@reports[@report_name]['report_design'],
|
92
|
+
@reports[@report_name]['report_processor'])
|
98
93
|
|
99
94
|
render :template => "old_sql/report/print.html.erb"
|
100
95
|
end
|
@@ -106,9 +101,6 @@ module OldSql
|
|
106
101
|
end
|
107
102
|
|
108
103
|
def _init
|
109
|
-
#todo add Devise support
|
110
|
-
#@authorization_adapter.authorize(:index) if @authorization_adapter
|
111
|
-
@page_name = t("old_sql.report.pagename")
|
112
104
|
@host = self.request.host
|
113
105
|
@port = self.request.port
|
114
106
|
end
|
@@ -118,29 +110,9 @@ module OldSql
|
|
118
110
|
@reports = YAML.load(Erubis::Eruby.new(template).result)
|
119
111
|
end
|
120
112
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
-
#todo get processor name from @reports
|
125
|
-
|
126
|
-
if !@reports[report]['processor'].nil?
|
127
|
-
logger.info "Loading Processor old_sql/report_processor/#{@reports[report]['processor'].downcase}"
|
128
|
-
require "old_sql/report_processor/#{@reports[report]['processor'].downcase}"
|
129
|
-
processor=eval("OldSql::ReportProcessor::#{@reports[report]['processor'].gsub("_","")}").new
|
130
|
-
|
131
|
-
else
|
132
|
-
logger.info "Loading Processor old_sql/report_processor/#{BASE_PROCESSOR}"
|
133
|
-
require "old_sql/report_processor/#{BASE_PROCESSOR}"
|
134
|
-
processor=eval("OldSql::ReportProcessor::#{BASE_PROCESSOR.capitalize}").new
|
135
|
-
end
|
136
|
-
rescue Exception=>e
|
137
|
-
logger.error e.message
|
138
|
-
logger.info "Loading Processor old_sql/report_processor/#{BASE_PROCESSOR}"
|
139
|
-
require "old_sql/report_processor/#{BASE_PROCESSOR}"
|
140
|
-
processor=eval("OldSql::ReportProcessor::#{BASE_PROCESSOR.capitalize}").new
|
141
|
-
end
|
142
|
-
|
143
|
-
processor
|
113
|
+
def load_base_processor
|
114
|
+
require "old_sql/report_processor/base"
|
115
|
+
OldSql::ReportProcessor::Base.new
|
144
116
|
end
|
145
117
|
|
146
118
|
def jqgrid_col_model
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
|
+
<title><%=OldSql.report_select_page_title%></title>
|
3
4
|
<%= stylesheet_link_tag "old_sql/old_sql.css" %>
|
4
5
|
<%= stylesheet_link_tag "old_sql/ui-lightness/jquery-ui-1.8.13.custom.css" %>
|
5
6
|
|
@@ -7,6 +8,7 @@
|
|
7
8
|
<%= javascript_include_tag "old_sql/jquery-ui-1.8.13.custom.min.js" %>
|
8
9
|
<%= javascript_include_tag "old_sql/jquery-ui-timepicker-addon.js" %>
|
9
10
|
<%= javascript_include_tag "old_sql/date_format.js" %>
|
11
|
+
<%= javascript_include_tag "old_sql/old_sql.js" %>
|
10
12
|
</head>
|
11
13
|
<body>
|
12
14
|
<%= yield %>
|
@@ -11,10 +11,10 @@ jQuery(document).ready(function(){
|
|
11
11
|
pager: false,
|
12
12
|
colNames: <%=jqgrid_col_names%>,
|
13
13
|
colModel: <%=jqgrid_col_model%>,
|
14
|
-
rowNum:
|
14
|
+
rowNum: <%=@row_num%>,
|
15
15
|
rowList: [10,20,30],
|
16
|
-
width:
|
17
|
-
height:
|
16
|
+
width: <%=@width%>,
|
17
|
+
height: <%=@height%>,
|
18
18
|
caption: "<%=@reports[@report_name]['value']%> Report"
|
19
19
|
});
|
20
20
|
});
|
@@ -1,87 +1,11 @@
|
|
1
1
|
<script>
|
2
2
|
var host = "<%=@host%>";
|
3
3
|
var port = "<%=@port%>";
|
4
|
-
var _report_sql = '';
|
5
|
-
var _report_loaded = false;
|
6
|
-
|
7
|
-
function report_selected()
|
8
|
-
{
|
9
|
-
var virality = jQuery("#report option:selected").attr('virality');
|
10
|
-
_report_sql = jQuery("#report option:selected").attr('report_sql');
|
11
|
-
|
12
|
-
if (virality == 'true')
|
13
|
-
{
|
14
|
-
jQuery("#select-generation").removeAttr('disabled');
|
15
|
-
}
|
16
|
-
else
|
17
|
-
{
|
18
|
-
jQuery("#select-generation").attr('disabled', 'disabled');
|
19
|
-
jQuery("#select-generation option:first").attr('selected','selected');
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
function load_report()
|
24
|
-
{
|
25
|
-
var src = "http://"+host+":"+port+"/sql/reports/datagrid/?report="+jQuery("#report").val()+
|
26
|
-
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+"&generation="+
|
27
|
-
jQuery("#select-generation").val()+"&report_sql="+
|
28
|
-
_report_sql;
|
29
|
-
|
30
|
-
jQuery('iframe').attr('src', src);
|
31
|
-
|
32
|
-
_report_loaded = true;
|
33
|
-
}
|
34
|
-
|
35
|
-
function print_report()
|
36
|
-
{
|
37
|
-
if(_report_loaded == false)
|
38
|
-
{
|
39
|
-
alert("You must select a report, and run it before continuing.");
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
|
43
|
-
var src = "http://"+host+":"+port+"/sql/reports/print/?report="+jQuery("#report").val()+
|
44
|
-
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+"&generation="+
|
45
|
-
jQuery("#select-generation").val()+"&report_sql="+_report_sql+"&desc="+jQuery("#report option:selected").attr('desc');
|
46
|
-
window.open(src,'Old SQL Report')
|
47
|
-
}
|
48
|
-
|
49
|
-
function export_report_to_excel()
|
50
|
-
{
|
51
|
-
if(_report_loaded == false)
|
52
|
-
{
|
53
|
-
alert("You must select a report, and run it before continuing.");
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
var src = "http://"+host+":"+port+"/sql/reports/query.csv/?report="+jQuery("#report").val()+
|
58
|
-
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+
|
59
|
-
"&generation="+jQuery("#select-generation").val()+"&report_sql="+
|
60
|
-
_report_sql+"&desc="+jQuery("#report option:selected").attr('desc');
|
61
|
-
window.open(src,'DB Report')
|
62
|
-
}
|
63
|
-
|
64
|
-
jQuery(document).ready(function($){
|
65
|
-
jQuery("#datepicker-start").datetimepicker();
|
66
|
-
jQuery("#datepicker-start").datetimepicker( "option", "dateFormat", "yy/mm/dd" );
|
67
|
-
jQuery("#datepicker-end").datetimepicker();
|
68
|
-
jQuery("#datepicker-end").datetimepicker( "option", "dateFormat", "yy/mm/dd" );
|
69
|
-
|
70
|
-
jQuery("#select-generation").attr('disabled', 'disabled');
|
71
|
-
|
72
|
-
var now = new Date();
|
73
|
-
var tomorrow = new Date();
|
74
|
-
var two_weeks_ago = new Date();
|
75
|
-
two_weeks_ago.setDate(now.getDate() - 14);
|
76
|
-
tomorrow.setDate(now.getDate() + 1);
|
77
|
-
jQuery("#datepicker-start").attr('value', two_weeks_ago.format("yyyy/mm/dd HH:MM:ss"));
|
78
|
-
jQuery("#datepicker-end").attr('value', tomorrow.format("yyyy/mm/dd HH:MM:ss"));
|
79
|
-
});
|
80
4
|
</script>
|
81
5
|
|
82
6
|
<div class="os-block">
|
83
7
|
<div class="ui-widget-header clearfix">
|
84
|
-
<%=
|
8
|
+
<%=OldSql.report_select_page_title%>
|
85
9
|
</div>
|
86
10
|
|
87
11
|
<form id="report-form" name="report-form" action="/oldsql/reports/query" method="POST">
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# Use this hook to configure the default report view, etc.
|
2
2
|
OldSql.setup do |config|
|
3
3
|
# ==> Default Report View Configuration
|
4
|
+
# The title of the Report Selection View.
|
5
|
+
config.report_select_page_title = 'Old SQL Reports'
|
6
|
+
|
4
7
|
# Configure the default report view. This setting will be used unless overridden
|
5
8
|
# in config/old_sql/reports.yml.
|
6
9
|
config.default_report_view = "jqgrid"
|
@@ -10,7 +13,7 @@ OldSql.setup do |config|
|
|
10
13
|
config.jqgrid_height = 630
|
11
14
|
|
12
15
|
# Width of the jqGrid component in the jqGrid report view.
|
13
|
-
config.
|
16
|
+
config.jqgrid_width = 800
|
14
17
|
|
15
18
|
# Number of rows to display in the jqGrid component in the jqGrid report view.
|
16
19
|
config.jqgrid_row_num = 25
|
@@ -10,7 +10,7 @@ module OldSql
|
|
10
10
|
|
11
11
|
ROUND_PRECISION = 2
|
12
12
|
|
13
|
-
def execute_query(report_sql,start_date,end_date,query_vars,design=nil)
|
13
|
+
def execute_query(report_sql,start_date,end_date,query_vars,design=nil,sub_processor=nil)
|
14
14
|
vars = {:start_date => start_date, :end_date => end_date}
|
15
15
|
|
16
16
|
if !query_vars.nil?
|
@@ -22,8 +22,6 @@ module OldSql
|
|
22
22
|
|
23
23
|
Rails.logger.debug sql
|
24
24
|
|
25
|
-
db = nil
|
26
|
-
|
27
25
|
begin
|
28
26
|
#todo change to a reporting db
|
29
27
|
db = ActiveRecord::Base.connection();
|
@@ -40,9 +38,15 @@ module OldSql
|
|
40
38
|
if design
|
41
39
|
parse_design(design, @resultset)
|
42
40
|
else
|
43
|
-
|
41
|
+
loaded_sub_processor = load_sub_processor(sub_processor)
|
42
|
+
|
43
|
+
if loaded_sub_processor.nil?
|
44
|
+
parse(@resultset)
|
45
|
+
else
|
46
|
+
@data = loaded_sub_processor.parse(@resultset)
|
47
|
+
end
|
44
48
|
end
|
45
|
-
|
49
|
+
|
46
50
|
@data
|
47
51
|
end
|
48
52
|
|
@@ -139,6 +143,21 @@ module OldSql
|
|
139
143
|
def isNumeric(s)
|
140
144
|
Float(s) != nil rescue false
|
141
145
|
end
|
146
|
+
|
147
|
+
def load_sub_processor sub_processor
|
148
|
+
return if sub_processor.nil?
|
149
|
+
|
150
|
+
loaded_sub_processor = nil
|
151
|
+
begin
|
152
|
+
Rails.logger.info "Loading Processor old_sql/report_processor/#{sub_processor.downcase}"
|
153
|
+
require "old_sql/report_processor/#{sub_processor.downcase}"
|
154
|
+
loaded_sub_processor=eval("OldSql::ReportProcessor::#{sub_processor.gsub("_","")}").new
|
155
|
+
rescue Exception=>e
|
156
|
+
Rails.logger.error e.message
|
157
|
+
end
|
158
|
+
|
159
|
+
loaded_sub_processor
|
160
|
+
end
|
142
161
|
end
|
143
162
|
end
|
144
163
|
end
|
data/lib/old_sql.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module OldSql
|
2
2
|
require 'old_sql/engine' if defined?(Rails)
|
3
3
|
|
4
|
+
# The title of the Report Selection View.
|
5
|
+
mattr_accessor :report_select_page_title
|
6
|
+
@@report_select_page_title = 'Old SQL Reports'
|
7
|
+
|
4
8
|
# The default report view. This setting will be used unless overridden in
|
5
9
|
# config/old_sql/reports.yml.
|
6
10
|
mattr_accessor :default_report_view
|
@@ -0,0 +1,76 @@
|
|
1
|
+
var _report_sql = '';
|
2
|
+
var _report_loaded = false;
|
3
|
+
|
4
|
+
function report_selected()
|
5
|
+
{
|
6
|
+
var virality = jQuery("#report option:selected").attr('virality');
|
7
|
+
_report_sql = jQuery("#report option:selected").attr('report_sql');
|
8
|
+
|
9
|
+
if (virality == 'true')
|
10
|
+
{
|
11
|
+
jQuery("#select-generation").removeAttr('disabled');
|
12
|
+
}
|
13
|
+
else
|
14
|
+
{
|
15
|
+
jQuery("#select-generation").attr('disabled', 'disabled');
|
16
|
+
jQuery("#select-generation option:first").attr('selected','selected');
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
function load_report()
|
21
|
+
{
|
22
|
+
var src = "http://"+host+":"+port+"/sql/reports/datagrid/?report="+jQuery("#report").val()+
|
23
|
+
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+"&generation="+
|
24
|
+
jQuery("#select-generation").val()+"&report_sql="+
|
25
|
+
_report_sql;
|
26
|
+
|
27
|
+
jQuery('iframe').attr('src', src);
|
28
|
+
|
29
|
+
_report_loaded = true;
|
30
|
+
}
|
31
|
+
|
32
|
+
function print_report()
|
33
|
+
{
|
34
|
+
if(_report_loaded == false)
|
35
|
+
{
|
36
|
+
alert("You must select a report, and run it before continuing.");
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
40
|
+
var src = "http://"+host+":"+port+"/sql/reports/print/?report="+jQuery("#report").val()+
|
41
|
+
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+"&generation="+
|
42
|
+
jQuery("#select-generation").val()+"&report_sql="+_report_sql+"&desc="+jQuery("#report option:selected").attr('desc');
|
43
|
+
window.open(src,'Old SQL Report')
|
44
|
+
}
|
45
|
+
|
46
|
+
function export_report_to_excel()
|
47
|
+
{
|
48
|
+
if(_report_loaded == false)
|
49
|
+
{
|
50
|
+
alert("You must select a report, and run it before continuing.");
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
|
54
|
+
var src = "http://"+host+":"+port+"/sql/reports/query.csv/?report="+jQuery("#report").val()+
|
55
|
+
"&start_date="+jQuery("#datepicker-start").val()+"&end_date="+jQuery("#datepicker-end").val()+
|
56
|
+
"&generation="+jQuery("#select-generation").val()+"&report_sql="+
|
57
|
+
_report_sql+"&desc="+jQuery("#report option:selected").attr('desc');
|
58
|
+
window.open(src,'DB Report')
|
59
|
+
}
|
60
|
+
|
61
|
+
jQuery(document).ready(function($){
|
62
|
+
jQuery("#datepicker-start").datetimepicker();
|
63
|
+
jQuery("#datepicker-start").datetimepicker( "option", "dateFormat", "yy/mm/dd" );
|
64
|
+
jQuery("#datepicker-end").datetimepicker();
|
65
|
+
jQuery("#datepicker-end").datetimepicker( "option", "dateFormat", "yy/mm/dd" );
|
66
|
+
|
67
|
+
jQuery("#select-generation").attr('disabled', 'disabled');
|
68
|
+
|
69
|
+
var now = new Date();
|
70
|
+
var tomorrow = new Date();
|
71
|
+
var two_weeks_ago = new Date();
|
72
|
+
two_weeks_ago.setDate(now.getDate() - 14);
|
73
|
+
tomorrow.setDate(now.getDate() + 1);
|
74
|
+
jQuery("#datepicker-start").attr('value', two_weeks_ago.format("yyyy/mm/dd HH:MM:ss"));
|
75
|
+
jQuery("#datepicker-end").attr('value', tomorrow.format("yyyy/mm/dd HH:MM:ss"));
|
76
|
+
});
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: old_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.51.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eddie Gonzales
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- public/javascripts/old_sql/jquery-1.5.1.min.js
|
137
137
|
- public/javascripts/old_sql/jquery-ui-1.8.13.custom.min.js
|
138
138
|
- public/javascripts/old_sql/jquery-ui-timepicker-addon.js
|
139
|
+
- public/javascripts/old_sql/old_sql.js
|
139
140
|
- public/stylesheets/old_sql/jqgrid/themes/default/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png
|
140
141
|
- public/stylesheets/old_sql/jqgrid/themes/default/images/ui-bg_flat_15_cd0a0a_40x100.png
|
141
142
|
- public/stylesheets/old_sql/jqgrid/themes/default/images/ui-bg_glass_100_e4f1fb_1x400.png
|
@@ -199,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
200
|
requirements:
|
200
201
|
- - ">="
|
201
202
|
- !ruby/object:Gem::Version
|
202
|
-
hash: -
|
203
|
+
hash: -3542637155537794698
|
203
204
|
segments:
|
204
205
|
- 0
|
205
206
|
version: "0"
|