vol1ura/Sat_9am_5km

View on GitHub
app/views/pages/additional-events.html.erb

Summary

Maintainability
Test Coverage
<% head_info :title, t('.title_html') %>
<% head_info :description, t('.description') %>
<h1><%= t '.title_html' %></h1>
<div class="row">
  <div class="col-md-6 offset-md-2">
    <table class="table">
      <thead>
        <tr>
          <td><%= t 'activities.index.event' %></td>
          <td><%= t 'activities.index.date' %></td>
        </tr>
      </thead>
      <tbody class="table-group-divider">
        <%
          event_data =
            CSV
              .read(File.join(__dir__, 'additional_events.csv'), headers: true, header_converters: :symbol)
              .each_with_object({}) { |row, obj| obj[row[:code_name]] = row[:time] if row[:domain].to_sym == top_level_domain }
        %>
        <% @country_events.where(code_name: event_data.keys).find_each do |event| %>
          <tr>
            <td><%= link_to event.name, event_path(event.code_name) %></td>
            <td><%= event_data[event.code_name] %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>