app/views/runs/_analyte.html.erb

Summary

Maintainability
Test Coverage
<% relevant_measurements = sample.measurements.collect {|measurement| measurement if measurement.sample == sample && measurement.analyte == analyte}.compact %>
<% stat_measurements = relevant_measurements.collect {|measurement| measurement if measurement.deleted == false}.compact %>
<% cv = RunsHelper.cv_help(stat_measurements) %>

<td class="cv-high-<%= cv > 10 || cv < 0 %>"  id="sample-<%= sample.id %>-<%= analyte.id %>">
  <table>

    <% relevant_measurements.each do |measurement| %>
      <% number = number_with_precision(measurement.amount,:precision => 4) %>
      <tr>
        <td>
          <% if sample.approved? %>
            <span class="deleted-<%=measurement.deleted?%>"><%= number %></span>
          <% else %>
            <%= link_to "#{number}",
                 {:controller => 'measurements',
                  :action => 'destroy',
                  :id => measurement.id,
                  :run_id => @run.id},
                 :method => 'delete',
                 :class => "deleted-#{measurement.deleted?}",
                :remote => true %>
          <% end %>
        </td>
      </tr>
    <% end %>
    <tr>
      <td>Mean:</td>
      <td><%= number_with_precision(RunsHelper.average(stat_measurements), :precision => 4) %></td>
    </tr>
    <tr>
      <td>CV:</td>
      <td><%= number_with_precision(RunsHelper.cv_help(stat_measurements), :precision=>4) %></td>
    </tr>
  </table>
</td>