<% content_for :title, "#{@aircraft.tail_number} Oil Analysis" %> <%= render "shared/aircraft_header", aircraft: @aircraft %> <% recent = @analyses.first(OilAnalysesController::COMPARE_SAMPLES) %>

Import a lab report

AvLab PDF reports: each sample on the report (including previous ones) is added unless it's already here.

<%= render "import", aircraft: @aircraft %>

Wear metal trends

<%= link_to "+ Add Oil Analysis", new_aircraft_oil_analysis_path(@aircraft), class: "btn-secondary btn-sm" %>
<% series = oil_trend_series(@analyses) %> <% if series.any? %> <%= line_chart series, ytitle: "ppm", height: "260px", curve: false, colors: OilAnalysesHelper::TREND_COLORS, legend: "bottom" %>

Lead is left out of the chart: it comes from 100LL fuel and reads in the thousands. Look for a steady trend rather than a single reading.

<% else %> <%= empty_state @analyses.any? ? "Add another sample to see trends." : "No oil analyses yet. Add one from your lab report." %> <% end %>
<% if recent.any?(&:any_results?) %>

Results (ppm)

Lab average for similar engines in (parentheses); red is <%= OilAnalysis::FLAG_RATIO %>× or more above it.
<% recent.each do |a| %><% end %> <% recent.each do |a| %><% end %> <% OilAnalysis::ELEMENTS.each do |el, (label, source)| %> <% next if recent.none? { _1.value(el) } %> <% recent.each do |a| %><% end %> <% end %>
Element<%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %>
Engine / oil hrs<%= a.engine_hours ? hours(a.engine_hours) : "—" %> / <%= a.oil_hours ? hours(a.oil_hours) : "—" %>
<%= label %><%= ppm_cell(a, el) %>
<% end %>

Samples

<% if @analyses.any? %>
<% @analyses.each do |a| %> <% end %>
SampledResultEngineEngine hrsOil hrsLabReport
<%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %> <%= oil_status_badge(a) %> <% if (flags = a.flagged_elements).any? %><%= flags.map { OilAnalysis.element_label(_1) }.to_sentence %> above average<% end %> <%= a.component&.to_s || "—" %> <%= a.engine_hours ? hours(a.engine_hours) : "—" %> <%= a.oil_hours ? hours(a.oil_hours) : "—" %> <%= [ a.lab, a.sample_number ].compact.join(" · ").presence || "—" %> <%= a.report.attached? ? link_to("PDF", rails_blob_path(a.report, disposition: :inline), class: "link", target: "_blank", rel: "noopener") : "—" %>
<% else %> <%= empty_state "No samples recorded." %> <% end %>