adhoq 0.3.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/adhoq/current_tables.js +23 -0
  4. data/app/assets/javascripts/adhoq/previewer.js +52 -0
  5. data/app/controllers/adhoq/queries_controller.rb +1 -1
  6. data/app/models/adhoq/execution.rb +5 -3
  7. data/app/models/adhoq/time_based_orders.rb +1 -1
  8. data/app/views/adhoq/application/_global_nav.html.erb +18 -0
  9. data/app/views/adhoq/current_tables/index.html.erb +53 -0
  10. data/app/views/adhoq/explains/create.html.erb +1 -0
  11. data/app/views/adhoq/explains/statement_invalid.html.erb +5 -0
  12. data/app/views/adhoq/previews/create.html.erb +21 -0
  13. data/app/views/adhoq/previews/statement_invalid.html.erb +4 -0
  14. data/app/views/adhoq/queries/_current_tables_leftbar.html.erb +14 -0
  15. data/app/views/adhoq/queries/_execution.html.erb +10 -0
  16. data/app/views/adhoq/queries/_form.html.erb +124 -0
  17. data/app/views/adhoq/queries/_queries.html.erb +16 -0
  18. data/app/views/adhoq/queries/_query.html.erb +67 -0
  19. data/app/views/adhoq/queries/edit.html.erb +13 -0
  20. data/app/views/adhoq/queries/index.html.erb +15 -0
  21. data/app/views/adhoq/queries/new.html.erb +12 -0
  22. data/app/views/adhoq/queries/show.html.erb +14 -0
  23. data/app/views/layouts/adhoq/application.html.erb +18 -0
  24. data/config/database.yml +25 -0
  25. data/lib/adhoq/configuration.rb +1 -0
  26. data/lib/adhoq/engine.rb +1 -1
  27. data/lib/adhoq/executor/connection_wrapper.rb +12 -8
  28. data/lib/adhoq/global_variable.rb +1 -0
  29. data/lib/adhoq/storage.rb +1 -0
  30. data/lib/adhoq/storage/cache.rb +27 -0
  31. data/lib/adhoq/version.rb +1 -1
  32. data/spec/factories/adhoq_queries.rb +9 -9
  33. data/spec/models/adhoq/execution_spec.rb +18 -0
  34. metadata +44 -71
  35. data/app/assets/javascripts/adhoq/current_tables.js.coffee +0 -18
  36. data/app/assets/javascripts/adhoq/previewer.js.coffee +0 -34
  37. data/app/views/adhoq/application/_global_nav.html.slim +0 -12
  38. data/app/views/adhoq/current_tables/index.html.slim +0 -34
  39. data/app/views/adhoq/explains/create.html.slim +0 -2
  40. data/app/views/adhoq/explains/statement_invalid.html.slim +0 -5
  41. data/app/views/adhoq/previews/create.html.slim +0 -12
  42. data/app/views/adhoq/previews/statement_invalid.html.slim +0 -5
  43. data/app/views/adhoq/queries/_current_tables_leftbar.html.slim +0 -9
  44. data/app/views/adhoq/queries/_execution.html.slim +0 -10
  45. data/app/views/adhoq/queries/_form.html.slim +0 -93
  46. data/app/views/adhoq/queries/_queries.html.slim +0 -14
  47. data/app/views/adhoq/queries/_query.html.slim +0 -48
  48. data/app/views/adhoq/queries/edit.html.slim +0 -11
  49. data/app/views/adhoq/queries/index.html.slim +0 -11
  50. data/app/views/adhoq/queries/new.html.slim +0 -10
  51. data/app/views/adhoq/queries/show.html.slim +0 -11
  52. data/app/views/layouts/adhoq/application.html.slim +0 -15
@@ -1,18 +0,0 @@
1
- loadCurrentTableTabOnce = ($el)->
2
- $el.load($el.find('a.loading').attr('href'))
3
-
4
- Adhoq.toggleCurrentTables = (action, elements)->
5
- loadCurrentTableTabOnce($('#current-tables'))
6
-
7
- $main = $(elements.main)
8
- $tables = $(elements.tables)
9
-
10
- if action is 'show'
11
- $main.addClass('col-md-6').removeClass('col-md-12')
12
- $tables.addClass('col-md-6').show()
13
- else
14
- $main.addClass('col-md-12').removeClass('col-md-6')
15
- $tables.addClass('col-md-6').hide()
16
-
17
- true
18
-
@@ -1,34 +0,0 @@
1
- class Previewer
2
- constructor: (@el)->
3
-
4
- init: ->
5
- @el.on 'adhoq:updatePreview', => @update()
6
-
7
- @el.on 'click', =>
8
- @el.trigger 'adhoq:updatePreview'
9
- false
10
-
11
- update: ->
12
- jQuery.ajax(
13
- type: @el.data('method'),
14
- url: @el.attr('href'),
15
- data: {query: @source()},
16
- complete: (xhr)=>
17
- @result().html(xhr.responseText)
18
- )
19
-
20
- source: ->
21
- $(@el.data('source')).val()
22
-
23
- result: ->
24
- $(@el.data('result'))
25
-
26
- Adhoq.enablePreview = ($el)->
27
- (new Previewer($el)).init()
28
-
29
- Adhoq.enablePreviewKeybordShortCut= ($textarea, previewSelector)->
30
- $textarea.on 'keyup', (ev)->
31
- if(ev.ctrlKey && ev.keyCode is 82)
32
- $(previewSelector).trigger('adhoq:updatePreview')
33
-
34
- false
@@ -1,12 +0,0 @@
1
- nav#global-nav.navbar.navbar-default(role='navigation')
2
- .container-fluid
3
- .navbar-header
4
- = link_to 'Adhoq', root_path, class: 'navbar-brand'
5
- .navbar-collapse.collapse
6
- ul.nav.navbar-nav.navbar-right
7
- - if main_app.respond_to?(:root_path)
8
- li
9
- = link_to main_app.root_path do
10
- i.fa.fa-arrow-circle-right.fa-pad-r
11
- | Main app
12
-
@@ -1,34 +0,0 @@
1
- h3
2
- i.fa.fa-database.fa-pad-r
3
- | Current tables
4
- small= "Version #{schema_version}"
5
- .pull-right
6
- button.close[data-trigger="toggleCurrentTables" role='close']
7
- span[aria-hidden=true] ×
8
-
9
- ul.list-unstyled.tables
10
- - @ar_classes.each do |ar_class|
11
- - first_record = ar_class.unscoped.order(table_order_key(ar_class)).first
12
-
13
- li.ar_class data-table-name=ar_class.table_name
14
- table.table.table-striped.table-hover.table-bordered
15
- caption
16
- span.name= ar_class.table_name
17
- small.count #{ar_class.unscoped.count} rows
18
- thead
19
- tr
20
- th.col-sm-1.pk PK
21
- th.col-sm-3.name Name
22
- th.col-sm-2.type Type
23
- th.col-sm-1.null Non-Null
24
- th.col-sm-2.limit Limit
25
- th.col-sm-3.default Default
26
- tbody
27
- - ar_class.columns.each do |column|
28
- tr
29
- td.pk.icon= column.name == ar_class.primary_key ? icon_fa('check-circle') : ''
30
- td.monospace= column.name
31
- td= column.type
32
- td.null.icon= column.null ? '' : icon_fa('check')
33
- td.limit.number= column.limit
34
- td= column.default
@@ -1,2 +0,0 @@
1
- pre
2
- = @result
@@ -1,5 +0,0 @@
1
- p.statement-invalid.alert.alert-danger
2
- strong= @statement_invalid.cause.class
3
- br
4
- = @statement_invalid.cause.message
5
-
@@ -1,12 +0,0 @@
1
- p.note #{@result.rows.size} rows
2
-
3
- table.table.table-striped.table-focus
4
- thead
5
- tr
6
- - @result.header.each do |column|
7
- th= column
8
- tbody
9
- - @result.rows.take(100).each do |row|
10
- tr
11
- - row.each do |val|
12
- td= val
@@ -1,5 +0,0 @@
1
- p.statement-invalid.alert.alert-danger
2
- strong= @statement_invalid.cause.class
3
- br
4
- = @statement_invalid.cause.message
5
-
@@ -1,9 +0,0 @@
1
- #current-tables
2
- a.loading[href=current_tables_path]
3
-
4
- javascript:
5
- $(function() {
6
- $(document).on('click', '[data-trigger="toggleCurrentTables"]', function($ev) {
7
- Adhoq.toggleCurrentTables($($ev.target).attr('role'), {main: '#main', tables: '#current-tables'});
8
- })
9
- });
@@ -1,10 +0,0 @@
1
- tr[exec]
2
- td.wip
3
- td.created_at= exec.created_at.localtime.iso8601
4
- td.status
5
- = exec.status_label
6
- td.report
7
- - if exec.success?
8
- = link_to(query_execution_path(query, exec, format: exec.report_format), class: 'btn btn-sm btn-default') do
9
- i.fa.fa-download.fa-pad-r
10
- = exec.report_format
@@ -1,93 +0,0 @@
1
- = form_for query, html: {class: 'form query-form', role: 'form'} do |f|
2
- .page-header
3
- h1
4
- = f.label :query, title, class: 'control-label'
5
- .pull-right
6
- a.btn.btn-default.btn-sm[href='#' data-trigger='toggleCurrentTables' role='show']
7
- i.fa.fa-database.fa-pad-r
8
- | Show tables
9
-
10
- .form-group
11
- = f.text_area :query, class: 'form-control', rows: 15, required: true
12
-
13
- .modal.fade#nameAndDesc[role='dialog']
14
- .modal-dialog
15
- .modal-content
16
- .modal-header
17
- button.close[data-dismiss='modal' aria-label='Close']
18
- button.close[type='button' data-dismiss='modal' aria-label='Close']
19
- span[aria-hidden='true'] ×
20
-
21
- h4 Add name and description to query
22
- .modal-body
23
- .form-horizontal
24
- .form-group
25
- = f.label :name, class: 'control-label col-sm-2'
26
- .col-sm-8
27
- = f.text_field :name, class: 'form-control', required: true
28
-
29
- .form-group
30
- = f.label :description, class: 'control-label col-sm-2'
31
- .col-sm-8
32
- = f.text_area :description, class: 'form-control', required: true
33
- .modal-footer
34
- button.btn.btn-primary.center-block
35
- i.fa.fa-floppy-o.fa-pad-r
36
- | Save
37
-
38
- .actions
39
- - if query.persisted?
40
- = link_to query do
41
- i.fa.fa-arrow-left.fa-pad-r
42
- | Cancel
43
- - else
44
- = link_to :queries do
45
- i.fa.fa-arrow-left.fa-pad-r
46
- | Back to Index
47
-
48
- .pull-right
49
- = link_to '#nameAndDesc', class: 'btn btn-default btn-sm', data: {toggle: 'modal', target: '#nameAndDesc'} do
50
- i.fa.fa-floppy-o.fa-pad-r
51
- | Save as...
52
-
53
- ul.nav.nav-tabs[role='tablist']
54
- li.active
55
- a[role='tab' data-toggle='tab' href='#preview' ]
56
- i.fa.fa-eye.fa-pad-r
57
- | Preview
58
- li
59
- a[role='tab' data-toggle='tab' href='#explain' ]
60
- i.fa.fa-info.fa-pad-r
61
- | Explain
62
-
63
- #previews.tab-content
64
- #preview.tab-pane.active
65
- h3
66
- | Query preview
67
- small
68
- = link_to preview_path, class: 'js-preview-button', data: {source: '#query_query', result: '.js-preview-result', remote: true, method: 'POST'} do
69
- i.fa.fa-refresh.fa-pad-r[data-title='Refresh preview']
70
- | Refresh
71
-
72
- .js-preview-result
73
- .alert.alert-info Preview is shown here
74
-
75
- #explain.tab-pane
76
- h3
77
- | Query explain
78
- small
79
- = link_to explain_path, class: 'js-explain-button', data: {source: '#query_query', result: '.js-explain-result', remote: true, method: 'POST'} do
80
- i.fa.fa-refresh.fa-pad-r[data-title='Refresh explain']
81
- | Refresh
82
-
83
- .js-explain-result
84
- .alert.alert-info Explain result is shown here
85
-
86
- javascript:
87
- $(function() {
88
- Adhoq.enablePreview($('#preview a.js-preview-button'));
89
- Adhoq.enablePreview($('#explain a.js-explain-button'));
90
-
91
- Adhoq.enablePreviewKeybordShortCut($('#query_query'), '#previews .tab-pane.active a:has(".fa-refresh")')
92
- });
93
-
@@ -1,14 +0,0 @@
1
- - highlight ||= nil
2
- section
3
- = link_to :root, class: 'btn btn-default new-query btn-sm center-block' do
4
- i.fa.fa-plus-square.fa-pad-r
5
- | New query
6
-
7
- ol.queries-index.list-unstyled
8
- - queries.each do |query|
9
- - css = (query == highlight) ? 'panel-success' : 'panel-default'
10
- li.panel[query, class= css]
11
- .panel-heading
12
- h2= link_to query.name, query_path(query)
13
- p.panel-body.description= query.description
14
-
@@ -1,48 +0,0 @@
1
- section.query
2
- .page-header
3
- h1
4
- = query.name
5
- .pull-right
6
- = link_to [:edit, query], class: 'btn btn-default btn-sm' do
7
- i.fa.fa-pencil.fa-pad-r
8
- | Edit
9
- .pull-right
10
- = link_to 'Delete', query, class: 'btn btn-default btn-sm', :method => :delete, data: { confirm: 'Are you sure?' }
11
- .clearfix
12
- small= "Updated at #{l(query.updated_at, format: :short)}"
13
- p.description= query.description
14
-
15
- css:
16
- #{Rouge::Themes::Github.render(scope: '.highlight')}
17
-
18
- = raw query.query_with_highlight
19
-
20
- section.new-execution
21
- h2 Create report
22
- = form_for [query, query.executions.build], html: {role: 'form'} do |f|
23
- .form-inline.form-group.report_format
24
- = f.label :report_format
25
- = f.select :report_format, f.object.supported_formats, {}, class: 'form-control'
26
- - if query.parameters.present?
27
- h4 Query parameters
28
- .form-group.query_parameters
29
- - query.parameters.each do |param_name|
30
- .form-inline.query_parameter
31
- = label_tag "parameters_#{param_name}", "#{param_name}"
32
- = query_parameter_field(param_name)
33
- .form-group
34
- = f.submit 'Create report', class: 'btn btn-default'
35
-
36
- section.past-executions
37
- h2 Reports
38
- table.executions.table.table-striped.table-hover
39
- thead
40
- tr
41
- th.wip  
42
- th.created_at= human(Adhoq::Execution, :created_at)
43
- th.status= human(Adhoq::Execution, :status)
44
- th.report
45
- tbody
46
- - query.executions.recent_first.each do |exec|
47
- - next if exec.report.try(:on_the_fly?)
48
- = render 'execution', query: query, exec: exec
@@ -1,11 +0,0 @@
1
- .col-md-12
2
- ol.breadcrumb
3
- li= link_to 'Index', :queries
4
- li= link_to query_friendly_name(@query), @query
5
- li.active Edit
6
-
7
- #main.col-md-12
8
- section.edit-query
9
- = render 'form', query: @query, title: "Edit query > #{query_friendly_name(@query)}"
10
-
11
- = render 'current_tables_leftbar'
@@ -1,11 +0,0 @@
1
- .col-md-12
2
- ol.breadcrumb
3
- li.active Index
4
-
5
- #queries.col-md-3
6
- section.queries
7
- = render 'queries', queries: @queries
8
-
9
- #the-query.col-md-9
10
- - if first_query = @queries.first
11
- = render 'query', query: first_query
@@ -1,10 +0,0 @@
1
- .col-md-12
2
- ol.breadcrumb
3
- li= link_to 'Index', :queries
4
- li.active New query
5
-
6
- #main.col-md-12
7
- section.new-query
8
- = render 'form', query: @query, title: 'New query'
9
-
10
- = render 'current_tables_leftbar'
@@ -1,11 +0,0 @@
1
- .col-md-12
2
- ol.breadcrumb
3
- li= link_to 'Index', :queries
4
- li.active= query_friendly_name(@query)
5
-
6
- #queries.col-md-3
7
- section.queries
8
- = render 'queries', queries: Adhoq::Query.recent_first, highlight: @query
9
-
10
- #the-query.col-md-9
11
- = render 'query', query: @query
@@ -1,15 +0,0 @@
1
- doctype html
2
- html
3
- head
4
- title Adhoq
5
- = stylesheet_link_tag 'adhoq/application', media: 'all'
6
- = javascript_include_tag 'adhoq/application'
7
- = csrf_meta_tags
8
-
9
- body
10
- .container
11
- = render 'global_nav'
12
-
13
- #contents.row
14
- = yield
15
-