mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Track oil analysis reports; import AvLab PDFs
New Oil Analysis tab: one record per oil sample with dates, hours, the lab's verdict and comments, ppm results for 12 wear metals with the lab's averages, and the report PDF. Shows wear-metal trends, a side-by-side history table, and flags readings 1.5x or more above the lab average. AvLab report PDFs can be imported: every sample on the report (current and previous) is added unless already recorded, the engine is matched by serial number, and reports for another tail number are refused. The parser reads positioned text and drops the hidden color-code layer that overlaps results. Adds the pdf-reader gem. Test fixture is a rebuilt report with a dummy header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c6e7af8e6
commit
d519aa9aae
24 files changed
+3456
-2
No files matched your search
@@ -0,0 +1,29 @@
|
||||
class CreateOilAnalyses < ActiveRecord::Migration[8.1]
|
||||
ELEMENTS = %i[iron copper nickel chromium silver magnesium aluminum lead silicon titanium tin molybdenum].freeze
|
||||
|
||||
def change
|
||||
# One lab report (spectrographic oil analysis) per oil sample.
|
||||
create_table :oil_analyses do |t|
|
||||
t.references :aircraft, null: false, foreign_key: true
|
||||
t.references :component, foreign_key: true # the engine sampled
|
||||
t.date :sample_date, null: false
|
||||
t.date :analysis_date
|
||||
t.string :lab
|
||||
t.string :sample_number
|
||||
t.decimal :engine_hours, precision: 8, scale: 1 # TSN/TSO at sampling
|
||||
t.decimal :oil_hours, precision: 6, scale: 1
|
||||
t.decimal :filter_hours, precision: 6, scale: 1
|
||||
t.decimal :oil_added, precision: 6, scale: 2 # quarts added since last change
|
||||
t.string :status, null: false, default: "normal"
|
||||
t.text :lab_comments
|
||||
t.text :notes
|
||||
# Wear metals and contaminants, ppm; *_avg is the lab's average for similar engines.
|
||||
ELEMENTS.each do |el|
|
||||
t.decimal el, precision: 8, scale: 1
|
||||
t.decimal :"#{el}_avg", precision: 8, scale: 1
|
||||
end
|
||||
t.timestamps
|
||||
end
|
||||
add_index :oil_analyses, %i[aircraft_id sample_date]
|
||||
end
|
||||
end
|
||||
Generated
+48
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_06_150000) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_06_160000) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -423,6 +423,51 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_06_150000) do
|
||||
t.index ["stc_document_id"], name: "index_major_records_on_stc_document_id"
|
||||
end
|
||||
|
||||
create_table "oil_analyses", force: :cascade do |t|
|
||||
t.integer "aircraft_id", null: false
|
||||
t.integer "component_id"
|
||||
t.date "sample_date", null: false
|
||||
t.date "analysis_date"
|
||||
t.string "lab"
|
||||
t.string "sample_number"
|
||||
t.decimal "engine_hours", precision: 8, scale: 1
|
||||
t.decimal "oil_hours", precision: 6, scale: 1
|
||||
t.decimal "filter_hours", precision: 6, scale: 1
|
||||
t.decimal "oil_added", precision: 6, scale: 2
|
||||
t.string "status", default: "normal", null: false
|
||||
t.text "lab_comments"
|
||||
t.text "notes"
|
||||
t.decimal "iron", precision: 8, scale: 1
|
||||
t.decimal "iron_avg", precision: 8, scale: 1
|
||||
t.decimal "copper", precision: 8, scale: 1
|
||||
t.decimal "copper_avg", precision: 8, scale: 1
|
||||
t.decimal "nickel", precision: 8, scale: 1
|
||||
t.decimal "nickel_avg", precision: 8, scale: 1
|
||||
t.decimal "chromium", precision: 8, scale: 1
|
||||
t.decimal "chromium_avg", precision: 8, scale: 1
|
||||
t.decimal "silver", precision: 8, scale: 1
|
||||
t.decimal "silver_avg", precision: 8, scale: 1
|
||||
t.decimal "magnesium", precision: 8, scale: 1
|
||||
t.decimal "magnesium_avg", precision: 8, scale: 1
|
||||
t.decimal "aluminum", precision: 8, scale: 1
|
||||
t.decimal "aluminum_avg", precision: 8, scale: 1
|
||||
t.decimal "lead", precision: 8, scale: 1
|
||||
t.decimal "lead_avg", precision: 8, scale: 1
|
||||
t.decimal "silicon", precision: 8, scale: 1
|
||||
t.decimal "silicon_avg", precision: 8, scale: 1
|
||||
t.decimal "titanium", precision: 8, scale: 1
|
||||
t.decimal "titanium_avg", precision: 8, scale: 1
|
||||
t.decimal "tin", precision: 8, scale: 1
|
||||
t.decimal "tin_avg", precision: 8, scale: 1
|
||||
t.decimal "molybdenum", precision: 8, scale: 1
|
||||
t.decimal "molybdenum_avg", precision: 8, scale: 1
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["aircraft_id", "sample_date"], name: "index_oil_analyses_on_aircraft_id_and_sample_date"
|
||||
t.index ["aircraft_id"], name: "index_oil_analyses_on_aircraft_id"
|
||||
t.index ["component_id"], name: "index_oil_analyses_on_component_id"
|
||||
end
|
||||
|
||||
create_table "sessions", force: :cascade do |t|
|
||||
t.integer "user_id", null: false
|
||||
t.string "ip_address"
|
||||
@@ -512,6 +557,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_06_150000) do
|
||||
add_foreign_key "major_records", "documents", column: "form_337_document_id", on_delete: :nullify
|
||||
add_foreign_key "major_records", "documents", column: "stc_document_id", on_delete: :nullify
|
||||
add_foreign_key "major_records", "logbook_entries", on_delete: :nullify
|
||||
add_foreign_key "oil_analyses", "aircraft"
|
||||
add_foreign_key "oil_analyses", "components"
|
||||
add_foreign_key "sessions", "users"
|
||||
add_foreign_key "share_tokens", "aircraft"
|
||||
add_foreign_key "share_tokens", "users", column: "created_by_id", on_delete: :nullify
|
||||
|
||||
Reference in new issue
Block a user