Unverified transcriptions, PM templates, ICA inspections, W&B, AD watch

- Entries transcribed by Claude are unverified (with Claude's confidence)
  until an owner checks them against the scan: badge, filter, "mark
  verified" stepping through the rest
- Preventive maintenance templates on new logbook entries, keyed to Part 43
  Appendix A(c), setting the entry type and pilot certificate (43.3(g))
- An STC's ICA can become a tracked recurring inspection, linked from its
  major record
- Weight & balance: history of empty weight/CG (linked to the 337 that
  changed them), loading stations and CG envelope from the POH, and a live
  calculator for takeoff and landing weight/CG; shown on the status report
- New ADs: weekly Federal Register search per aircraft (aircraft, engine
  and propeller models, or custom terms); track or dismiss each; included
  in the weekly reminder
- Archives carry the new records; brakeman: explicit params, reviewed
  About-page links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 10:49:29 -05:00
1 parent bed07386ef
commit 6cab81332e
49 files changed
+1197 -35

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
# Newly published ADs that may apply: check now, track or dismiss, and the
# search terms used.
class AdAlertsController < ApplicationController
include AircraftScoped
before_action :require_owner!
before_action :set_alert, only: %i[track dismiss]
rate_limit to: 5, within: 1.minute, only: :check, with: -> { redirect_to aircraft_airworthiness_directives_path(@aircraft), alert: "Try again in a minute." }
def check
found = AdWatch.new(@aircraft).check!
redirect_to aircraft_airworthiness_directives_path(@aircraft, anchor: "new-ads"),
notice: found.any? ? "Found #{helpers.pluralize(found.size, 'newly published AD')} to review." : "No new ADs found for #{AdWatch.new(@aircraft).terms.to_sentence}."
rescue AdWatch::Error => e
redirect_to aircraft_airworthiness_directives_path(@aircraft), alert: "Couldn't check for new ADs: #{e.message}."
end
def track
ad = @alert.track!
log_event("ad", "AD tracked from the Federal Register: #{ad.name}")
redirect_to edit_aircraft_airworthiness_directive_path(@aircraft, ad),
notice: "#{ad.name} is now tracked. Set its applicability and recurrence from the AD's text, then record compliance or mark it not applicable."
end
def dismiss
@alert.dismiss!
redirect_to aircraft_airworthiness_directives_path(@aircraft, anchor: "new-ads"), notice: "Dismissed."
end
def terms
@aircraft.update!(ad_watch_terms: params[:ad_watch_terms].to_s.strip.first(500).presence)
redirect_to aircraft_airworthiness_directives_path(@aircraft, anchor: "new-ads"), notice: "Search terms saved."
end
private
def set_alert = @alert = @aircraft.ad_alerts.find(params[:id])
end
@@ -9,6 +9,7 @@ class AirworthinessDirectivesController < ApplicationController
@history = AdCompliance.for_aircraft(@aircraft).recent_first
.includes(:component, :logbook_entry, airworthiness_directive: :document, inspection_record: :inspection_type)
@attachable = AirworthinessDirective.where.not(id: @aircraft.applicable_ads.select(:id)).ordered if owner?
@alerts = @aircraft.ad_alerts.pending
end
def new
+17 -1
View File
@@ -7,6 +7,11 @@ class InspectionTypesController < ApplicationController
def new
@inspection_type = InspectionType.new(required: true, recurring: true)
@applies_to_airframe = true
if (@major_record = ica_record)
@inspection_type.name = "ICA: #{@major_record.title}".first(120)
@applies_to_airframe = @major_record.component.nil?
@inspection_type.components = [ @major_record.component ] if @major_record.component
end
end
def create
@@ -14,11 +19,17 @@ class InspectionTypesController < ApplicationController
InspectionType.transaction do
@inspection_type.save!
apply_applicability(@inspection_type, to_airframe: applies_to_airframe?, component_ids: applicable_component_ids)
ica_record&.update!(ica_inspection_type: @inspection_type)
end
log_event("inspection", "Inspection type added: #{@inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection type added."
if (record = ica_record)
redirect_to aircraft_major_record_path(@aircraft, record), notice: "ICA inspection added. Record when it was last done to see when it's next due."
else
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection type added."
end
rescue ActiveRecord::RecordInvalid
@applies_to_airframe = applies_to_airframe?
@major_record = ica_record
render :new, status: :unprocessable_entity
end
@@ -46,6 +57,11 @@ class InspectionTypesController < ApplicationController
private
# Creating the inspection an STC's ICA calls for (from its major record).
def ica_record
@aircraft.major_records.find_by(id: params[:major_record_id]) if params[:major_record_id].present?
end
def set_type
@inspection_type = @aircraft.applicable_inspection_types.find(params[:id])
end
@@ -0,0 +1,22 @@
# The aircraft's loading stations (arms) and CG envelope, from the POH, for
# the loading calculator.
class LoadingSetupsController < ApplicationController
include AircraftScoped
before_action :require_owner!
def edit
@setup = @aircraft.loading_setup
end
def update
permitted = params.fetch(:setup, {}).permit(:fuel_lb_per_gal, stations: %i[name arm max fuel], envelope: %i[weight cg])
@setup = LoadingSetup.from_params(permitted.to_h)
if @setup.valid?
@aircraft.update!(loading_stations: @setup.stations_json, cg_envelope: @setup.envelope)
log_event("aircraft", "Loading stations and CG envelope updated")
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: "Loading setup saved."
else
render :edit, status: :unprocessable_entity
end
end
end
+14 -2
View File
@@ -1,16 +1,28 @@
class LogbookEntriesController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_entry, only: %i[show edit update destroy]
before_action :set_entry, only: %i[show edit update destroy verify]
def index
@query = params[:q]
@log_type = params[:log_type].presence
scope = @aircraft.logbook_entries.search(@query).recent_first.includes(:document)
scope = scope.where(log_type: @log_type) if @log_type
@unverified_only = params[:unverified] == "1"
scope = scope.unverified if @unverified_only
@unverified_count = @aircraft.logbook_entries.unverified.count
@entries = scope.limit(500)
end
# Someone has checked a transcribed entry against the scan.
def verify
@entry.update!(verified: true)
log_event("logbook", "Transcribed logbook entry verified: #{@entry.date}")
next_entry = @aircraft.logbook_entries.unverified.order(:date, :id).first
redirect_to next_entry ? aircraft_logbook_entry_path(@aircraft, next_entry) : aircraft_logbook_entries_path(@aircraft),
notice: next_entry ? "Verified. Here's the next one to check." : "Verified. All transcribed entries are checked."
end
def show; end
def new
@@ -51,7 +63,7 @@ class LogbookEntriesController < ApplicationController
def entry_params
p = params.require(:logbook_entry).permit(:log_type, :entry_type, :date, :text, :signoff_person,
:signoff_location, :aircraft_hours_at_entry, :document_id, :page_number,
:signoff_certificate_type, :signoff_certificate_number, :inspection_result)
:signoff_certificate_type, :signoff_certificate_number, :inspection_result, :verified)
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
@@ -0,0 +1,57 @@
# Weight & balance history and the loading calculator (pilots use it; owners
# keep the records and the loading setup).
class WeightBalanceRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: :index
before_action :set_record, only: %i[edit update destroy]
def index
@records = @aircraft.weight_balance_records.recent_first.includes(:major_record, :document)
@current = @records.first
end
def new
last = @aircraft.current_weight_balance
@record = @aircraft.weight_balance_records.new(date: Date.current, max_gross_weight: last&.max_gross_weight,
major_record_id: params[:major_record_id])
end
def create
@record = @aircraft.weight_balance_records.new(record_params)
if @record.save
log_event("aircraft", "Weight & balance recorded: #{@record.empty_weight} lb @ #{@record.empty_arm} in")
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: "Weight & balance saved."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event("aircraft", "Weight & balance updated (#{@record.date})")
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: "Weight & balance updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event("aircraft", "Weight & balance record deleted (#{@record.date})")
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: "Record deleted."
end
private
def set_record = @record = @aircraft.weight_balance_records.find(params[:id])
def record_params
p = params.require(:weight_balance_record).permit(:date, :empty_weight, :empty_arm, :max_gross_weight, :reason, :notes,
:major_record_id, :document_id)
p[:major_record_id] = scoped_id(@aircraft.major_records, p[:major_record_id])
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
end