gitcoinco/code_fund_ads

View on GitHub
app/views/campaign_dailies/_table.html.erb

Summary

Maintainability
Test Coverage
<%= table_wrapper do %>
  <%= paginated_table do %>
    <%= table_head do %>
      <%= table_row header: true do %>
        <%= table_column "Date" %>
        <% if @campaign.standard? %>
          <%= table_column "Spend" %>
          <%= table_column "Impressions" %>
        <% end %>
        <%= table_column "Clicks" %>
        <% if @campaign.standard? %>
          <%= table_column "CTR" %>
          <%= table_column "CPM" %>
          <%= table_column "CPC" %>
        <% end %>
      <% end %>
    <% end %>
    <%= table_body do %>
      <!-- Totals Row -->
      <% if @summary %>
        <%= table_row do %>
          <%= table_data do %>
            <strong>Totals</strong>
          <% end %>
          <% if @campaign.standard? %>
            <%= table_data @summary.gross_revenue.format %>
            <%= table_data number_with_delimiter(@summary.impressions_count) %>
          <% end %>
          <%= table_data number_with_delimiter(@summary.clicks_count) %>
          <% if @campaign.standard? %>
            <%= table_data number_to_percentage(@summary.click_rate, precision: 2) %>
            <%= table_data number_with_delimiter(@summary.cpm.format) %>
            <%= table_data number_with_delimiter(@summary.cpc.format) %>
          <% end %>
        <% end %>
      <% end %>
      <!-- /Totals Row -->
      <% if @daily_summaries.exists? %>
        <%= render partial: "/campaign_dailies/tr", collection: @daily_summaries, as: :daily_summary %>
      <% else %>
        <%= render "/shared/no_data_alert" %>
      <% end %>
    <% end %>
  <% end %>
  <%= pagination_wrapper do %>
    <span><%== pagy_bootstrap_nav(pagy) %></span>
    <%= pagy_entries(pagy) %>
  <% end if pagy.pages > 1 %>
<% end %>