<div class="content">
  <h1>Tune</h1>

  <table class="table">
    <thead>
      <tr>
        <th>Setting</th>
        <th style="width: 20%;">Value</th>
      </tr>
    </thead>
    <tbody>
      <% @settings.each do |setting, value| %>
        <tr>
          <td><%= setting %></td>
          <td><%= value %></td>
        </tr>
      <% end %>
    </tbody>
  </table>

  <% version_parts = @database.server_version.split(" ").first.split(".") %>
  <p>Check out <%= link_to "PgTune", "https://pgtune.leopard.in.ua/", target: "_blank" %> for recommendations. DB version is <%= version_parts[0].to_i >= 10 ? version_parts[0] : version_parts.first(2).join(".") %>.</p>
</div>

<% if @autovacuum_settings %>
  <div class="content">
    <h1>Autovacuum</h1>

    <table class="table">
      <thead>
        <tr>
          <th>Setting</th>
          <th style="width: 20%;">Value</th>
        </tr>
      </thead>
      <tbody>
        <% @autovacuum_settings.each do |setting, value| %>
          <tr>
            <td><%= setting %></td>
            <td>
              <%= value %>
              <% if setting == :autovacuum_vacuum_cost_limit && value == "-1" %>
                <span class="text-muted"><%= @database.vacuum_settings[:vacuum_cost_limit] %></span>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <p>Check out <%= link_to "Autovacuum Tuning Basics", "https://blog.2ndquadrant.com/autovacuum-tuning-basics/", target: "_blank" %> for recommendations.</p>
  </div>
<% end %>
