<commit_before><div class="content">
  <pre><code style="max-height: 230px; overflow: hidden;" onclick="this.style.maxHeight = 'none';"><%= @query %></code></pre>
  <script>
    highlightQueries()
  </script>

  <% if @explainable_query %>
    <p>
      <%= button_to "Explain", explain_path, params: {query: @explainable_query}, form: {target: "_blank"}, class: "btn btn-info" %>
    </p>
  <% end %>

  <% if @origins && @origins.keys.select { |k| k.length > 0 }.any? %>
    <table style="table-layout: auto;">
      <thead>
        <tr>
          <th colspan="2">
            <div style="float: right;">Approx. Time</div>
            Origin
          </th>
        </tr>
      </thead>
      <tbody>
        <% @origins.sort_by { |o, c| [-c, o.to_s] }.each do |origin, count| %>
          <tr>
            <td class="origin" style="width: 90%;">
              <% if origin.length > 0 %>
                <%= origin %>
              <% else %>
                <span class="text-muted">Unknown</span>
              <% end %>
            </td>
            <td style="text-align: right; width: 10%;">
              <% pct = (100.0 * count / @total_count).round %>
              <% if pct == 0 %>
                &lt; 1%
              <% else %>
                <%= pct %>%
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  <% end %>

  <!-- chart -->
  <% if @chart_data %>
    <h1>Total Time <small>ms</small></h1>
    <div id="chart-1" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-1", <%= json_escape(@chart_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false})
    </script>

    <h1>Average Time <small>ms</small></h1>
    <div id="chart-2" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-2", <%= json_escape(@chart2_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false})
    </script>

    <h1>Calls</h1>
    <div id="chart-3" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-3", <%= json_escape(@chart3_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false})
    </script>
  <% else %>
    <p>
      Enable
      <%= link_to "historical query stats", "https://github.com/ankane/pghero", target: "_blank" %>
      to see more details
    </p>
  <% end %>

  <!-- table info -->
  <% if @tables.any? %>
    <h1>Tables</h1>
    <table>
      <thead>
        <tr>
          <th style="width: 25%;">Name</th>
          <th style="width: 25%;">Rows</th><commit_msg>Improved query details charts<commit_after><div class="content">
  <pre><code style="max-height: 230px; overflow: hidden;" onclick="this.style.maxHeight = 'none';"><%= @query %></code></pre>
  <script>
    highlightQueries()
  </script>

  <% if @explainable_query %>
    <p>
      <%= button_to "Explain", explain_path, params: {query: @explainable_query}, form: {target: "_blank"}, class: "btn btn-info" %>
    </p>
  <% end %>

  <% if @origins && @origins.keys.select { |k| k.length > 0 }.any? %>
    <table style="table-layout: auto;">
      <thead>
        <tr>
          <th colspan="2">
            <div style="float: right;">Approx. Time</div>
            Origin
          </th>
        </tr>
      </thead>
      <tbody>
        <% @origins.sort_by { |o, c| [-c, o.to_s] }.each do |origin, count| %>
          <tr>
            <td class="origin" style="width: 90%;">
              <% if origin.length > 0 %>
                <%= origin %>
              <% else %>
                <span class="text-muted">Unknown</span>
              <% end %>
            </td>
            <td style="text-align: right; width: 10%;">
              <% pct = (100.0 * count / @total_count).round %>
              <% if pct == 0 %>
                &lt; 1%
              <% else %>
                <%= pct %>%
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  <% end %>

  <!-- chart -->
  <% if @chart_data %>
    <h1>Total Time <small>ms</small></h1>
    <div id="chart-1" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-1", <%= json_escape(@chart_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false, dataset: {pointHoverRadius: 0}, library: {tooltips: {intersect: false, mode: "index"}}})
    </script>

    <h1>Average Time <small>ms</small></h1>
    <div id="chart-2" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-2", <%= json_escape(@chart2_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false, dataset: {pointHoverRadius: 0}, library: {tooltips: {intersect: false, mode: "index"}}})
    </script>

    <h1>Calls</h1>
    <div id="chart-3" class="chart" style="margin-bottom: 20px;">Loading...</div>
    <script>
      new Chartkick.LineChart("chart-3", <%= json_escape(@chart3_data.to_json).html_safe %>, {colors: ["#5bc0de"], legend: false, dataset: {pointHoverRadius: 0}, library: {tooltips: {intersect: false, mode: "index"}}})
    </script>
  <% else %>
    <p>
      Enable
      <%= link_to "historical query stats", "https://github.com/ankane/pghero", target: "_blank" %>
      to see more details
    </p>
  <% end %>

  <!-- table info -->
  <% if @tables.any? %>
    <h1>Tables</h1>
    <table>
      <thead>
        <tr>
          <th style="width: 25%;">Name</th>
          <th style="width: 25%;">Rows</th>
{'fraction_non_alphanumeric': 0.20845323741007193, 'fraction_numerical': 0.017805755395683454, 'mean_word_length': 2.1941412981045376, 'pattern_counts': {'":': 0, '<': 181, '<?xml version=': 0, '>': 185, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7380007', 'n_tokens_mistral': 2058, 'n_tokens_neox': 1859, 'n_words': 393}