<% title @query.name %>
<%= link_to "Home", root_path, class: "btn btn-primary", style: "vertical-align: top; margin-right: 5px;" %>

<%= @query.name %>

<%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default" %> <%= link_to "Fork", new_query_path(variable_params.merge(statement: @query.statement, data_source: @query.data_source)), class: "btn btn-info" %> <% if !@error && @success %> <%= button_to "Download", run_queries_path(statement: @statement, query_id: @query.id, format: "csv"), class: "btn btn-primary" %> <% end %>
<% if @sql_errors.any? %>
<% end %> <% if @query.description.present? %>

<%= @query.description %>

<% end %> <% if @bind_vars.any? %>
<% date_vars = ["start_time", "end_time"] %> <% if (date_vars - @bind_vars).empty? %> <% @bind_vars = @bind_vars - date_vars %> <% else %> <% date_vars = nil %> <% end %> <% @bind_vars.each_with_index do |var, i| %> <%= label_tag var, var %> <% if (data = @smart_vars[var]) %> <%= select_tag var, options_for_select([[nil, nil]] + data, selected: params[var]), style: "margin-right: 20px; width: 200px; display: none;" %> <% else %> <%= text_field_tag var, params[var], style: "width: 120px; margin-right: 20px;", autofocus: i == 0 && !var.end_with?("_at") && !params[var], class: "form-control" %> <% if var.end_with?("_at") %> <% end %> <% end %> <% end %> <% if date_vars %> <% date_vars.each do |var| %> <%= hidden_field_tag var, params[var] %> <% end %> <%= label_tag nil, date_vars.join(" & ") %>
Select a time range
<% end %>
<% end %>
<%= @statement %>
<% if @success %>

Loading...

<% end %>