sql-jarvis 2.0.9 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/blazer/main.js +4 -3
  3. data/app/helpers/blazer/base_helper.rb +1 -1
  4. data/app/views/blazer/_nav.html.haml +12 -0
  5. data/app/views/blazer/{_variables.html.erb → _variables.html.haml} +35 -57
  6. data/app/views/blazer/check_mailer/failing_checks.html.haml +6 -0
  7. data/app/views/blazer/check_mailer/state_change.html.haml +31 -0
  8. data/app/views/blazer/checks/_form.html.haml +51 -0
  9. data/app/views/blazer/checks/edit.html.haml +2 -0
  10. data/app/views/blazer/checks/index.html.haml +48 -0
  11. data/app/views/blazer/checks/new.html.haml +2 -0
  12. data/app/views/blazer/dashboards/_form.html.haml +64 -0
  13. data/app/views/blazer/dashboards/edit.html.haml +2 -0
  14. data/app/views/blazer/dashboards/new.html.haml +2 -0
  15. data/app/views/blazer/dashboards/show.html.haml +33 -0
  16. data/app/views/blazer/queries/{_form.html.erb → _form.html.haml} +54 -81
  17. data/app/views/blazer/queries/_tips.html.haml +92 -0
  18. data/app/views/blazer/queries/docs.html.haml +115 -0
  19. data/app/views/blazer/queries/edit.html.haml +2 -0
  20. data/app/views/blazer/queries/{home.html.erb → home.html.haml} +38 -58
  21. data/app/views/blazer/queries/new.html.haml +2 -0
  22. data/app/views/blazer/queries/run.html.haml +153 -0
  23. data/app/views/blazer/queries/schema.html.haml +43 -0
  24. data/app/views/blazer/queries/show.html.haml +50 -0
  25. data/app/views/layouts/blazer/application.html.haml +19 -0
  26. data/lib/blazer/version.rb +1 -1
  27. metadata +38 -24
  28. data/app/views/blazer/_nav.html.erb +0 -15
  29. data/app/views/blazer/check_mailer/failing_checks.html.erb +0 -6
  30. data/app/views/blazer/check_mailer/state_change.html.erb +0 -47
  31. data/app/views/blazer/checks/_form.html.erb +0 -79
  32. data/app/views/blazer/checks/edit.html.erb +0 -3
  33. data/app/views/blazer/checks/index.html.erb +0 -69
  34. data/app/views/blazer/checks/new.html.erb +0 -3
  35. data/app/views/blazer/dashboards/_form.html.erb +0 -76
  36. data/app/views/blazer/dashboards/edit.html.erb +0 -3
  37. data/app/views/blazer/dashboards/new.html.erb +0 -3
  38. data/app/views/blazer/dashboards/show.html.erb +0 -51
  39. data/app/views/blazer/queries/_tips.html.erb +0 -69
  40. data/app/views/blazer/queries/docs.html.erb +0 -131
  41. data/app/views/blazer/queries/edit.html.erb +0 -2
  42. data/app/views/blazer/queries/new.html.erb +0 -2
  43. data/app/views/blazer/queries/run.html.erb +0 -202
  44. data/app/views/blazer/queries/schema.html.erb +0 -58
  45. data/app/views/blazer/queries/show.html.erb +0 -76
  46. data/app/views/layouts/blazer/application.html.erb +0 -25
@@ -1,3 +0,0 @@
1
- <% blazer_title "Edit Dashboard" %>
2
-
3
- <%= render partial: "form" %>
@@ -1,3 +0,0 @@
1
- <% blazer_title "New Dashboard" %>
2
-
3
- <%= render partial: "form" %>
@@ -1,51 +0,0 @@
1
- <% blazer_title @dashboard.name %>
2
-
3
- <div class="topbar">
4
- <div class="container">
5
- <div class="row" style="padding-top: 13px;">
6
- <div class="col-sm-9">
7
- <%= render partial: "blazer/nav" %>
8
- <h3 style="line-height: 34px; display: inline; margin-left: 5px;">
9
- <%= @dashboard.name %>
10
- </h3>
11
- </div>
12
- <div class="col-sm-3 text-right">
13
- <%= link_to "Edit", edit_dashboard_path(@dashboard, variable_params), class: "btn btn-info" %>
14
- </div>
15
- </div>
16
- </div>
17
- </div>
18
-
19
- <div style="margin-bottom: 60px;"></div>
20
-
21
- <% if @data_sources.any? { |ds| ds.cache_mode != "off" } %>
22
- <p class="text-muted" style="float: right;">
23
- Some queries may be cached
24
- <%= link_to "Refresh", refresh_dashboard_path(@dashboard, variable_params), method: :post %>
25
- </p>
26
- <% end %>
27
-
28
- <% if @bind_vars.any? %>
29
- <%= render partial: "blazer/variables", locals: {action: dashboard_path(@dashboard)} %>
30
- <% else %>
31
- <div style="padding-bottom: 15px;"></div>
32
- <% end %>
33
-
34
- <% @queries.each_with_index do |query, i| %>
35
- <div class="chart-container">
36
- <h4><%= link_to query.friendly_name, query_path(query, variable_params), target: "_blank" %></h4>
37
- <div id="chart-<%= i %>" class="chart">
38
- <p class="text-muted">Loading...</p>
39
- </div>
40
- </div>
41
- <script>
42
- <%= blazer_js_var "data", {statement: query.statement, query_id: query.id, data_source: query.data_source, only_chart: true} %>
43
-
44
- runQuery(data, function (data) {
45
- $("#chart-<%= i %>").html(data)
46
- $("#chart-<%= i %> table").stupidtable()
47
- }, function (message) {
48
- $("#chart-<%= i %>").addClass("query-error").html(message)
49
- });
50
- </script>
51
- <% end %>
@@ -1,69 +0,0 @@
1
- <small class='text-muted'>
2
- <h5>
3
- <i class="far fa-lightbulb"></i>
4
- ProTip!
5
- <%= link_to 'more...', docs_queries_path, target: :_blank, style: "float: right; font-weight: 200" %>
6
- </h5>
7
- <ul class='list-unstyled' id='proTip'>
8
- <li>
9
- <strong>Command + S</strong> to backup your SQL string.
10
- </li>
11
- <li>
12
- Set column name to <strong>*_date</strong> to format DateTime to <strong><%= Time.current.strftime('%Y/%m/%d') %></strong>
13
- </li>
14
- <li>
15
- Set column name to <strong>*_time</strong> to format DateTime to <strong><%= Time.current.strftime('%H:%M') %></strong>
16
- </li>
17
-
18
- <% if @data_source.smart_variables.any? %>
19
- <% @data_source.smart_variables.keys.each do |key| %>
20
- <li>
21
- <strong><i class="fas fa-caret-square-down"></i></strong>
22
- Use <code>{<%= key %>}</code> to get a dropdown of values.
23
- </li>
24
- <% end %>
25
- <li>
26
- <strong><i class="fas fa-caret-square-down"></i></strong>
27
- Use <code>{start_time}</code> and <code>{end_time}</code> for a date range selector.
28
- </li>
29
- <li>
30
- <strong><i class="fas fa-caret-square-down"></i></strong>
31
- End a variable name with <code>_at</code> for a date selector.
32
- </li>
33
- <% end %>
34
-
35
- <li>
36
- <strong><i class="fas fa-chart-line"></i> Chart:</strong>
37
- 2+ columns - timestamp, numeric(s)</li>
38
- <li>
39
- <strong><i class="fas fa-chart-line"></i> Chart:</strong>
40
- 3 columns - timestamp, string, numeric
41
- </li>
42
- <li>
43
- <strong><i class="far fa-chart-bar"></i> Chart:</strong>
44
- 2+ columns - string, numeric(s)
45
- </li>
46
- <li>
47
- <strong><i class="far fa-chart-bar"></i> Chart:</strong>
48
- 3 columns - string, string, numeric
49
- </li>
50
- <li>
51
- <strong>Scatter Chart:</strong>
52
- 2 columns - both numeric
53
- </li>
54
- <li>
55
- <strong><i class="fas fa-chart-pie"></i> Chart:</strong>
56
- 2 columns - string, numeric - and last column named <code>pie</code>
57
- </li>
58
- <li>
59
- <strong><i class="fas fa-globe-americas"></i> Chart:</strong>
60
- Named <code>latitude</code> and <code>longitude</code>, or <code>lat</code> and <code>lon</code>, or <code>lat</code> and <code>lng</code>
61
- </li>
62
- <ul>
63
- </small>
64
-
65
- <script>
66
- var itemCount = $('ul#proTip li').length;
67
- var showIndex = Math.floor(Math.random() * Math.floor(itemCount)) + 1;
68
- $("ul#proTip li:nth-child(" + showIndex + ")").show();
69
- </script>
@@ -1,131 +0,0 @@
1
- <% blazer_title "Docs: #{@data_source.name}" %>
2
-
3
- <h1>Docs: <%= @data_source.name %></h1>
4
-
5
- <hr />
6
-
7
- <h2>Smart Variables</h2>
8
-
9
- <% if @smart_variables.any? %>
10
- <p>Use these variable names to get a dropdown of values.</p>
11
-
12
- <table class="table" style="max-width: 500px;">
13
- <thead>
14
- <tr>
15
- <th>Variable</th>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <% @smart_variables.each do |k, _| %>
20
- <tr>
21
- <td><code>{<%= k %>}</code></td>
22
- </tr>
23
- <% end %>
24
- </tbody>
25
- </table>
26
-
27
- <p>Use <code>{start_time}</code> and <code>{end_time}</code> for a date range selector. End a variable name with <code>_at</code> for a date selector.</p>
28
- <% else %>
29
- <p>None set - add them in <code>config/blazer.yml</code>.</p>
30
- <% end %>
31
-
32
- <h2>Linked Columns</h2>
33
-
34
- <% if @linked_columns.any? %>
35
- <p>Use these column names to link results to other pages.</p>
36
-
37
- <table class="table" style="max-width: 500px;">
38
- <thead>
39
- <tr>
40
- <th style="width: 20%;">Name</th>
41
- <th>URL</th>
42
- </tr>
43
- </thead>
44
- <tbody>
45
- <% @linked_columns.each do |k, v| %>
46
- <tr>
47
- <td><%= k %></td>
48
- <td><%= v %></td>
49
- </tr>
50
- <% end %>
51
- </tbody>
52
- </table>
53
-
54
- <p>Values that match the format of a URL will be linked automatically.</p>
55
- <% else %>
56
- <p>None set - add them in <code>config/blazer.yml</code>.</p>
57
- <% end %>
58
-
59
- <h2>Smart Columns</h2>
60
-
61
- <% if @smart_columns.any? %>
62
- <p>Use these column names to show additional data.</p>
63
-
64
- <table class="table" style="max-width: 500px;">
65
- <thead>
66
- <tr>
67
- <th>Name</th>
68
- </tr>
69
- </thead>
70
- <tbody>
71
- <% @smart_columns.each do |k, _| %>
72
- <tr>
73
- <td><%= k %></td>
74
- </tr>
75
- <% end %>
76
- </tbody>
77
- </table>
78
- <% else %>
79
- <p>None set - add them in <code>config/blazer.yml</code>.</p>
80
- <% end %>
81
-
82
- <h2>Charts</h2>
83
-
84
- <p>Use specific combinations of column types to generate charts.</p>
85
-
86
- <table class="table" style="max-width: 500px;">
87
- <thead>
88
- <tr>
89
- <th style="width: 20%;">Chart</th>
90
- <th>Column Types</th>
91
- </tr>
92
- </thead>
93
- <tbody>
94
- <tr>
95
- <td>Line</td>
96
- <td>2+ columns - timestamp, numeric(s)</td>
97
- </tr>
98
- <tr>
99
- <td>Line</td>
100
- <td>3 columns - timestamp, string, numeric</td>
101
- </tr>
102
- <tr>
103
- <td>Column</td>
104
- <td>2+ columns - string, numeric(s)</td>
105
- </tr>
106
- <tr>
107
- <td>Column</td>
108
- <td>3 columns - string, string, numeric</td>
109
- </tr>
110
- <tr>
111
- <td>Scatter</td>
112
- <td>2 columns - both numeric</td>
113
- </tr>
114
- <tr>
115
- <td>Pie</td>
116
- <td>2 columns - string, numeric - and last column named <code>pie</code></td>
117
- </tr>
118
- <tr>
119
- <td>Map</td>
120
- <td>
121
- Named <code>latitude</code> and <code>longitude</code>, or <code>lat</code> and <code>lon</code>, or <code>lat</code> and <code>lng</code>
122
- <% if !blazer_maps? %>
123
- <br />
124
- <strong>Needs configured</strong>
125
- <% end %>
126
- </td>
127
- </tr>
128
- </tbody>
129
- </table>
130
-
131
- <p>Use the column name <code>target</code> to draw a line for goals.</p>
@@ -1,2 +0,0 @@
1
- <% blazer_title "Edit - #{@query.name}" %>
2
- <%= render partial: "form" %>
@@ -1,2 +0,0 @@
1
- <% blazer_title "New Query" %>
2
- <%= render partial: "form" %>
@@ -1,202 +0,0 @@
1
- <% if @error %>
2
- <div class="alert alert-danger"><%= @error.first(200) %></div>
3
- <% elsif !@success %>
4
- <% if @only_chart %>
5
- <p class="text-muted">Select variables</p>
6
- <% else %>
7
- <div class="alert alert-info">Can’t preview queries with variables...yet!</div>
8
- <% end %>
9
- <% else %>
10
- <% unless @only_chart %>
11
- <% if @cached_at || @just_cached %>
12
- <p class="text-muted" style="float: right;">
13
- <% if @cached_at %>
14
- Cached <%= time_ago_in_words(@cached_at, include_seconds: true) %> ago
15
- <% elsif !params[:data_source] %>
16
- Cached just now
17
- <% if @data_source.cache_mode == "slow" %>
18
- (over <%= "%g" % @data_source.cache_slow_threshold %>s)
19
- <% end %>
20
- <% end %>
21
-
22
- <% if @query && !params[:data_source] %>
23
- <%= link_to "Refresh", refresh_query_path(@query, variable_params), method: :post %>
24
- <% end %>
25
- </p>
26
- <% end %>
27
- <% end %>
28
- <% if @forecast_error %>
29
- <div class="alert alert-danger"><%= @forecast_error %></div>
30
- <% end %>
31
- <% if @rows.any? %>
32
- <% values = @rows.first %>
33
- <% chart_id = SecureRandom.hex %>
34
- <% column_types = @result.column_types %>
35
- <% chart_type = @result.chart_type %>
36
- <% chart_options = {id: chart_id} %>
37
- <% if ["line", "line2"].include?(chart_type) %>
38
- <% chart_options.merge!(min: nil) %>
39
- <% end %>
40
- <% if chart_type == "scatter" %>
41
- <% chart_options.merge!(library: {tooltips: {intersect: false}}) %>
42
- <% elsif ["bar", "bar2"].include?(chart_type) %>
43
- <% chart_options.merge!(library: {tooltips: {intersect: false, axis: 'x'}}) %>
44
- <% elsif chart_type != "pie" %>
45
- <% if column_types.size == 2 || @forecast %>
46
- <% chart_options.merge!(library: {tooltips: {intersect: false, axis: 'x'}}) %>
47
- <% else %>
48
- <%# chartjs axis: 'x' has poor behavior with multiple series %>
49
- <% chart_options.merge!(library: {tooltips: {intersect: false}}) %>
50
- <% end %>
51
- <% end %>
52
- <% series_library = {} %>
53
- <% target_index = @columns.index { |k| k.downcase == "target" } %>
54
- <% if target_index %>
55
- <% series_library[target_index - 1] = {pointStyle: "line", hitRadius: 5, borderColor: "#109618", pointBackgroundColor: "#109618", backgroundColor: "#109618"} %>
56
- <% end %>
57
- <% if @forecast %>
58
- <% color = "#54a3ee" %>
59
- <% series_library[1] = {borderDash: [8], borderColor: color, pointBackgroundColor: color, backgroundColor: color, pointHoverBackgroundColor: color} %>
60
- <% end %>
61
- <% if blazer_maps? && @markers.any? %>
62
- <div id="map" style="height: <%= @only_chart ? 300 : 500 %>px;"></div>
63
- <script>
64
- L.mapbox.accessToken = '<%= Blazer.mapbox_access_token %>';
65
- var map = L.mapbox.map('map', 'ankane.ioo8nki0');
66
- <%= blazer_js_var "markers", @markers %>
67
- var featureLayer = L.mapbox.featureLayer().addTo(map);
68
- var geojson = [];
69
- for (var i = 0; i < markers.length; i++) {
70
- var marker = markers[i];
71
- geojson.push({
72
- type: 'Feature',
73
- geometry: {
74
- type: 'Point',
75
- coordinates: [
76
- marker.longitude,
77
- marker.latitude
78
- ]
79
- },
80
- properties: {
81
- description: marker.title,
82
- 'marker-color': '#f86767',
83
- 'marker-size': 'medium'
84
- }
85
- });
86
- }
87
- featureLayer.setGeoJSON(geojson);
88
- map.fitBounds(featureLayer.getBounds());
89
- </script>
90
- <% elsif chart_type == "line" %>
91
- <% chart_data = @columns[1..-1].each_with_index.map{ |k, i| {name: blazer_series_name(k), data: @rows.map{ |r| [r[0], r[i + 1]] }, library: series_library[i]} } %>
92
- <%= line_chart chart_data, chart_options %>
93
- <% elsif chart_type == "line2" %>
94
- <%= line_chart @rows.group_by { |r| v = r[1]; (@boom[@columns[1]] || {})[v.to_s] || v }.each_with_index.map { |(name, v), i| {name: blazer_series_name(name), data: v.map { |v2| [v2[0], v2[2]] }, library: series_library[i]} }, chart_options %>
95
- <% elsif chart_type == "pie" %>
96
- <%= pie_chart @rows.map { |r| [(@boom[@columns[0]] || {})[r[0].to_s] || r[0], r[1]] }, chart_options %>
97
- <% elsif chart_type == "bar" %>
98
- <%= column_chart (values.size - 1).times.map { |i| name = @columns[i + 1]; {name: blazer_series_name(name), data: @rows.first(20).map { |r| [(@boom[@columns[0]] || {})[r[0].to_s] || r[0], r[i + 1]] } } }, chart_options %>
99
- <% elsif chart_type == "bar2" %>
100
- <% first_20 = @rows.group_by { |r| r[0] }.values.first(20).flatten(1) %>
101
- <% labels = first_20.map { |r| r[0] }.uniq %>
102
- <% series = first_20.map { |r| r[1] }.uniq %>
103
- <% labels.each do |l| %>
104
- <% series.each do |s| %>
105
- <% first_20 << [l, s, 0] unless first_20.find { |r| r[0] == l && r[1] == s } %>
106
- <% end %>
107
- <% end %>
108
- <%= column_chart first_20.group_by { |r| v = r[1]; (@boom[@columns[1]] || {})[v.to_s] || v }.each_with_index.map { |(name, v), i| {name: blazer_series_name(name), data: v.sort_by { |r2| labels.index(r2[0]) }.map { |v2| v3 = v2[0]; [(@boom[@columns[0]] || {})[v3.to_s] || v3, v2[2]] }} }, chart_options %>
109
- <% elsif chart_type == "scatter" %>
110
- <%= scatter_chart @rows, xtitle: @columns[0], ytitle: @columns[1], **chart_options %>
111
- <% elsif @only_chart %>
112
- <% if @rows.size == 1 && @rows.first.size == 1 %>
113
- <% v = @rows.first.first %>
114
- <% if v.is_a?(String) && v == "" %>
115
- <div class="text-muted">empty string</div>
116
- <% else %>
117
- <p style="font-size: 160px;"><%= blazer_format_value(@columns.first, v) %></p>
118
- <% end %>
119
- <% else %>
120
- <% @no_chart = true %>
121
- <% end %>
122
- <% end %>
123
-
124
- <% unless @only_chart && !@no_chart %>
125
- <% header_width = 100 / @columns.size.to_f %>
126
- <div class="results-container">
127
- <% if @columns == ["QUERY PLAN"] %>
128
- <pre><code><%= @rows.map { |r| r[0] }.join("\n") %></code></pre>
129
- <% elsif @columns == ["PLAN"] && @data_source.adapter == "druid" %>
130
- <pre><code><%= @rows[0][0] %></code></pre>
131
- <% else %>
132
- <p class="text-muted" style="margin-bottom: 10px; margin-top: 15px">
133
- <%= pluralize(@rows.size, "row") %>
134
- <% @checks.select(&:state).each do |check| %>
135
- &middot; <small class="check-state <%= check.state.parameterize.gsub("-", "_") %>"><%= link_to check.state.upcase, edit_check_path(check) %></small>
136
- <% if check.try(:message) %>
137
- &middot; <%= check.message %>
138
- <% end %>
139
- <% end %>
140
-
141
- <% if @query && @result.forecastable? && !params[:forecast] %>
142
- &middot;
143
- <%= link_to "Forecast", query_path(@query, {forecast: "t"}.merge(variable_params)) %>
144
- <% end %>
145
- <span class='pull-right'>
146
- <%- if @rows.size > 0 %>
147
- <%= link_to 'Copy to clipboard', '#results-table', class: 'click2CopyTable btn btn-xs btn-info' %>
148
- <% end %>
149
- </span>
150
- </p>
151
- <div class='scroll-content'>
152
- <table class="table results-table" id='results-table'>
153
- <thead>
154
- <tr>
155
- <% @columns.each_with_index do |key, i| %>
156
- <% type = @column_types[i] %>
157
- <% summany_popup = type.in?(['float', 'int']) && !key.end_with?('id') %>
158
- <th style="width: <%= header_width %>%;" data-sort="<%= type %>" data-popup=<%= summany_popup %>>
159
- <div style="min-width: <%= @min_width_types.include?(i) ? 180 : 60 %>px;">
160
- <%= key %>
161
- </div>
162
- </th>
163
- <% end %>
164
- </tr>
165
- </thead>
166
- <tbody>
167
- <% @rows.each do |row| %>
168
- <tr>
169
- <% row.each_with_index do |v, i| %>
170
- <% k = @columns[i] %>
171
- <td>
172
- <% if v.is_a?(Time) %>
173
- <% v = blazer_time_value(@data_source, k, v) %>
174
- <% end %>
175
-
176
- <% unless v.nil? %>
177
- <% if v.is_a?(String) && v == "" %>
178
- <div class="text-muted">empty string</div>
179
- <% elsif @linked_columns[k] %>
180
- <%= link_to blazer_format_value(k, v), @linked_columns[k].gsub("{value}", u(v.to_s)), target: "_blank" %>
181
- <% else %>
182
- <%= blazer_format_value(k, v) %>
183
- <% end %>
184
- <% end %>
185
-
186
- <% if v2 = (@boom[k] || {})[v.nil? ? v : v.to_s] %>
187
- <div class="text-muted"><%= v2 %></div>
188
- <% end %>
189
- </td>
190
- <% end %>
191
- </tr>
192
- <% end %>
193
- </tbody>
194
- </table>
195
- </div>
196
- <% end %>
197
- </div>
198
- <% end %>
199
- <% else %>
200
- <p class="text-muted text-center" style='margin-top: 15px'>No rows</p>
201
- <% end %>
202
- <% end %>