2026.11.1: offline flight logging fixed, inspections from logbook entries, life limits from installation, component inspections moved to inspection types

- Service worker keeps the Log Flight form when opened via Turbo, serves the offline page's script and icon, and treats 502/503/504 as offline; the offline page only links forms actually kept
- Serviced sub-components restart from the airframe time flown since the entry
- New logbook entries can complete inspections (recorded and linked to the entry)
- Components: replacement limit can count from installation (life limit)
- Component-level "Inspect every" / "Inspection critical" removed; a migration converts any unlinked settings into inspection types with a first record; component page lists its inspections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-12 07:30:59 -05:00
1 parent 7552e4a8a3
commit 352a38c7fb
28 files changed
+289 -69

No files matched your search

@@ -0,0 +1,8 @@
# A life-limited part that's cleaned and reused (e.g. a Challenger oil filter):
# its "replace every" limit counts from when it was installed (total time in
# service), not from its last service.
class AddReplacementFromInstallToComponents < ActiveRecord::Migration[8.1]
def change
add_column :components, :replacement_from_install, :boolean, default: false, null: false
end
end
@@ -0,0 +1,47 @@
# A component's own "Inspect every" (hours / days / months, "Inspection
# critical") only fed the coming-due list, counted from its last service, and
# never affected airworthiness. Inspection types linked to the component do
# all of that properly (records, airworthiness, logbook entries), so each
# setting becomes one: grounding if it was critical, else advisory, with a
# first record at the component's last service so the next due stays the same.
# Components that already had an inspection type linked ignored these fields,
# so they're just dropped.
class MoveComponentInspectionsToInspectionTypes < ActiveRecord::Migration[8.1]
def up
rows = select_all(<<~SQL).to_a
SELECT c.id, c.inspection_hours, c.inspection_days, c.inspection_months, c.inspection_critical,
c.overhaul_date, c.hours_since_overhaul
FROM components c
WHERE c.status <> 'DISPOSED'
AND (COALESCE(c.inspection_hours, 0) > 0 OR COALESCE(c.inspection_days, 0) > 0 OR COALESCE(c.inspection_months, 0) > 0)
AND NOT EXISTS (SELECT 1 FROM components_inspection_types ci WHERE ci.component_id = c.id)
SQL
[ Component, InspectionType, InspectionRecord ].each(&:reset_column_information)
rows.each do |row|
component = Component.find(row["id"])
critical = ActiveModel::Type::Boolean.new.cast(row["inspection_critical"])
type = InspectionType.create!(name: "#{component} #{component.model} inspection".squish.first(120), recurring: true,
required: critical, effect: critical ? "grounds" : "advisory",
recurring_hours: row["inspection_hours"].to_i, recurring_days: row["inspection_days"].to_i,
recurring_months: row["inspection_months"].to_i)
type.components << component
next unless (date = row["overhaul_date"])
aircraft = component.aircraft
hours = aircraft && [ aircraft.current_hours - row["hours_since_overhaul"].to_d, 0 ].max
InspectionRecord.create!(inspection_type: type, aircraft: aircraft, component: component, date: date, aircraft_hours: hours,
notes: "From the component's last service (its former \"Inspect every\" setting).")
end
remove_column :components, :inspection_hours
remove_column :components, :inspection_days
remove_column :components, :inspection_months
remove_column :components, :inspection_critical
end
def down
add_column :components, :inspection_hours, :integer
add_column :components, :inspection_days, :integer
add_column :components, :inspection_months, :integer
add_column :components, :inspection_critical, :boolean, default: true, null: false
end
end
Generated
+2 -5
View File
@@ -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_12_010000) do
ActiveRecord::Schema[8.1].define(version: 2026_11_12_030000) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -341,21 +341,18 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_12_010000) do
t.date "overhaul_date"
t.integer "tbo_hours"
t.integer "tbo_days"
t.integer "inspection_hours"
t.integer "inspection_days"
t.integer "replacement_hours"
t.integer "replacement_days"
t.boolean "tbo_critical", default: true, null: false
t.boolean "on_condition", default: false, null: false
t.boolean "inspection_critical", default: true, null: false
t.boolean "replacement_critical", default: false, null: false
t.boolean "replacement_from_install", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "expires_on"
t.string "overhaul_kind"
t.integer "replacement_months"
t.integer "tbo_months"
t.integer "inspection_months"
t.index ["aircraft_id"], name: "index_components_on_aircraft_id"
t.index ["component_type_id"], name: "index_components_on_component_type_id"
t.index ["parent_component_id"], name: "index_components_on_parent_component_id"