Business intelligence made simple
Revert "Set tables in controller"
Andrew Kanecb6fe61c6a24
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 85f715b1..d22b1be5 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -13,7 +13,6 @@ module Blazerbefore_action :ensure_database_urlbefore_action :set_query, only: [:show, :edit, :update, :destroy]- before_action :set_tables, only: [:new, :edit]def index@queries = Blazer::Query.order(:name).includes(:creator)@@ -136,10 +135,6 @@ module Blazer@query = Blazer::Query.find(params[:id].to_s.split("-").first)end- def set_tables- @tables = tables- end-def query_paramsparams.require(:query).permit(:name, :description, :statement)end@@ -218,6 +213,7 @@ module Blazerrows, error = run_statement(Blazer::Connection.send(:sanitize_sql_array, ["SELECT table_name, column_name, ordinal_position, data_type FROM information_schema.columns WHERE table_schema = ?", schema]))Hash[ rows.group_by{|r| r["table_name"] }.map{|t, f| [t, f.sort_by{|f| f["ordinal_position"] }.map{|f| f.slice("column_name", "data_type") }] }.sort_by{|t, f| t } ]end+ helper_method :tablesendenddiff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erbindex 7e9c46ca..28dc311d 100644--- a/app/views/blazer/queries/_form.html.erb+++ b/app/views/blazer/queries/_form.html.erb@@ -16,7 +16,7 @@<%= link_to "Back", :back %><span class="text-muted" style="margin-left: 20px;"> Use {start_time} and {end_time} for time ranges</span></div>- <%= select_tag :table_names, options_for_select([["Preview table", nil]] + @tables.keys), style: "margin-right: 20px; width: 240px;" %>+ <%= select_tag :table_names, options_for_select([["Preview table", nil]] + tables.keys), style: "margin-right: 20px; width: 240px;" %><%= link_to "Run", "#", class: "btn btn-info", id: "run", style: "vertical-align: top;" %></div></div>