SpeciesFileGroup/taxonworks

View on GitHub
app/views/administration/data_health.html.erb

Summary

Maintainability
Test Coverage
<h1> Administration - Data health </h1>
<%= link_to 'Back', administration_path() %>

<h2> DelayedJobs </h2>
<div class="flexbox separate-bottom">
  <div class="panel content separate-left">
    <%= table_from_hash_tag delayed_job_queue %>
  </div>
</div>

<p><em class="feedback feedback-danger"> Bad things if data listed below here. </em></p>

<h2> Stale DwcOccurrences (record present but object gone) </h2>
<%= button_to 'Sweep (delete these DwcOccurrences)', sweep_stale_dwc_occurrences_path, method: :post, class: [:button, 'button-delete'] %><br/>
<div class="flexbox separate-bottom">
  <% %w{CollectionObject AssertedDistribution}.each_with_index do |k, i| -%>
    <div class="panel content separate-left">
     <h3> <%= k %> </h3>
        <%= table_from_hash_tag( stale_dwc_occurrences(k).sort ) %>
    </div>
  <% end %>
</div>



<div class="flexbox">
  <div class="item item1">
    <% [Source, TaxonName].each do |k| -%>
      <h2> <%= k -%> without cached values </h2>
      <table>
        <tr>
          <th>Id</th>
          <th>Link</th>
          <th>Last updated</th>
          <th>Project</th>
        </tr>

        <% k.where(cached: nil).each_with_index do |o, i| -%>
          <tr>
            <%= content_tag(:td, o.id) %>
            <%= content_tag(:td, object_link(o)) %>
            <%= content_tag(:td, time_ago_in_words(o.updated_at) + " ago", class: :subtle) %>
            <%= content_tag(:td, (o.respond_to?(:project) ? o.project.name : nil ) ) %>
          </tr>
        <% end %>
      </table>
    <% end %>
  </div>
</div>

<div class="flexbox">
  <div class="item item1">
    <% [Source, TaxonName, CollectionObject, CollectingEvent].each do |k| -%>
      <% query = k.where('created_at < ?', '1970-1-1') %>
      <% next if query.count == 0 %>
      <h2> <%= k -%> with dubious created_at values (older than 1970, capped at 100 of <%= query.count %> records)</h2>
      <table>
        <tr>
          <th>Id</th>
          <th>Link</th>
          <th>Created at</th>
          <th>Project</th>
        </tr>

        <% query.limit(100).each_with_index do |o, i| -%>
          <tr>
            <%= content_tag(:td, o.id) %>
            <%= content_tag(:td, object_link(o)) %>
            <%= content_tag(:td, time_ago_in_words(o.created_at) + " ago", class: :subtle) %>
            <%= content_tag(:td, (o.respond_to?(:project) ? o.project.name : nil ) ) %>
          </tr>
        <% end %>
      </table>
    <% end %>
  </div>
</div>