noesya/osuny

View on GitHub
app/views/admin/communication/websites/connections/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, Communication::Website::Connection.model_name.human(count: 2) %>
<% content_for :title_right, @connections.count %>

<div class="row">
  <div class="col-xl-6">
    <%= osuny_label 'Objets indirects' %>
    <table class="table">
      <thead>
        <tr>
          <th>Type</th>
          <th>Quantité</th>
          <th>Connexions</th>
        </tr>
      </thead>
      <tbody>
        <% @connections.pluck(:indirect_object_type).uniq.each do |type| %>
          <tr>
            <td><%= link_to type, indirect_object_admin_communication_website_connections_path(type) %></td>
            <td><%= @connections.where(indirect_object_type: type).pluck(:indirect_object_id).uniq.count %></td>
            <td><%= @connections.where(indirect_object_type: type).count %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
  <div class="col-xl-6">
    <%= osuny_label 'Sources directes' %>
    <table class="table">
      <thead>
        <tr>
          <th>Type</th>
          <th>Quantité</th>
          <th>Connexions</th>
        </tr>
      </thead>
      <tbody>
        <% @connections.pluck(:direct_source_type).uniq.each do |type| %>
          <tr>
            <td><%= link_to type, direct_source_admin_communication_website_connections_path(type) if type %></td>
            <td><%= @connections.where(direct_source_type: type).pluck(:direct_source_id).uniq.count %></td>
            <td><%= @connections.where(direct_source_type: type).count %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>