mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- 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>
37 lines
1.5 KiB
Ruby
37 lines
1.5 KiB
Ruby
# An AD published in the Federal Register that may apply to an aircraft,
|
|
# waiting for the owner to track it (as an AD to comply with) or dismiss it.
|
|
class AdAlert < ApplicationRecord
|
|
STATUSES = %w[new tracked dismissed].freeze
|
|
|
|
belongs_to :aircraft
|
|
belongs_to :airworthiness_directive, optional: true
|
|
|
|
validates :fr_document_number, presence: true, uniqueness: { scope: :aircraft_id }
|
|
validates :status, inclusion: { in: STATUSES }
|
|
|
|
scope :pending, -> { where(status: "new").order(publication_date: :desc) }
|
|
|
|
# Tracks it: the AD (shared across aircraft, matched by number) is linked
|
|
# to this aircraft, so it counts against airworthiness until complied with.
|
|
def track!
|
|
transaction do
|
|
ad = AirworthinessDirective.find_by(name: ad_number) if ad_number.present?
|
|
ad ||= AirworthinessDirective.create!(
|
|
name: ad_number.presence || fr_document_number, short_description: summary, effective_date: effective_on,
|
|
document_url: html_url, docket_number: amendment, required_action: abstract.to_s.truncate(2000)
|
|
)
|
|
ad.aircraft << aircraft unless ad.aircraft.include?(aircraft)
|
|
update!(status: "tracked", airworthiness_directive: ad)
|
|
ad
|
|
end
|
|
end
|
|
|
|
def dismiss! = update!(status: "dismissed")
|
|
|
|
# "Requires …" from the abstract, else the title without its prefix.
|
|
def summary
|
|
requires = abstract.to_s[/This AD requires ([^.]+)\./, 1]
|
|
(requires ? "Requires #{requires}" : title.to_s.delete_prefix("Airworthiness Directives; ")).truncate(250)
|
|
end
|
|
end
|