<% if @query_stats_enabled && !@historical_query_stats_enabled %>
<%= button_to "Reset", reset_query_stats_path, class: "btn btn-danger", style: "float: right;" %>
<% end %>
<% if !@historical_query_stats_enabled %>
Queries
<% end %>
<% if @historical_query_stats_enabled %>
<%= render partial: "query_stats_slider" %>
<% elsif @database.query_stats_table_exists? && (columns = @database.missing_query_stats_columns).any? %>
Add missing columns to re-enable historical query stats.
<% @database.missing_query_stats_columns.each do |column| %>ALTER TABLE pghero_query_stats ADD COLUMN "<%= column %>" <%= column == "query_hash" ? "bigint" : "text" %>;
<% end %>
Then restart the web server.
<% end %>
<% if @query_stats_enabled %>
<% if @error %>
Cannot understand start or end time.
<% elsif @query_stats.any? || @historical_query_stats_enabled %>
<%= render partial: "queries_table", locals: {queries: @query_stats, sort_headers: true} %>
<% else %>
Stats are not available yet. Come back soon!
<% end %>
<% else %>
Query stats are not enabled.
<% end %>