<div align=center>
  <%= link("Module",
    to: "#{@conn.request_path}?for=module",
    class: "btn #{unless @conn.query_params["for"] == "trace", do: "active"}",
    style: "background-color: #e7e7e7; font-size: 20px;")
  %>
  <%= link("Trace",
    to: "#{@conn.request_path}?for=trace",
    class: "btn #{if @conn.query_params["for"] == "trace", do: "active"}",
    style: "background-color: #e7e7e7; font-size: 20px;")
  %>
<div>

<table class="table">
  <tr>
    <th>Function</th>
    <th>
      <%= link("Total query time (ms)",
        to: "#{@conn.request_path}?order=time&for=module",
        class: "btn #{if @conn.query_params["order"] == "time", do: "active"}",
        style: "background-color: #e7e7e7;")
      %>
    </th> 
    <th>
      <%= link("Calls",
        to: "#{@conn.request_path}?order=calls&for=module",
        class: "btn #{unless @conn.query_params["order"] == "time", do: "active"}",
        style: "background-color: #e7e7e7;")
      %>
    </th>
    <th>
      <%= link("Average query time (ms)",
        to: "#{@conn.request_path}?order=average&for=module",
        class: "btn #{unless Enum.member?(["time", "calls"], @conn.query_params["order"]), do: "active"}",
        style: "background-color: #e7e7e7;")
      %>
    </th>
  </tr>
  <%= for {_, {module_name, func, arity}, query_time, calls} <- @data do %>
    <tr>
      <td><%= full_module_name(module_name, func, arity) %></td>
      <td><%= query_time %></td>
      <td><%= calls %></td>
      <td><%= average_query_time(query_time, calls) %></td>
    </tr>
  <% end %>
</table>
