mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
New-AD search covers every installed component
- Besides the aircraft and engine/propeller models (and families), each in-use component is searched as maker + model designator and as component type + designator (e.g. "Champion 4301", "Magneto 4301"), so appliance ADs (magnetos, ELTs, radios, transponders) are found - A match records the component; tracking it makes the AD apply to that component instead of the airframe (ad_alerts.component_id) - Page hint, guide and README updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afaa1ca191
commit
d2f5ce1e92
9 files changed
+91
-20
No files matched your search
@@ -4,6 +4,7 @@ class AdAlert < ApplicationRecord
|
||||
STATUSES = %w[new tracked dismissed].freeze
|
||||
|
||||
belongs_to :aircraft
|
||||
belongs_to :component, optional: true
|
||||
belongs_to :airworthiness_directive, optional: true
|
||||
|
||||
validates :fr_document_number, presence: true, uniqueness: { scope: :aircraft_id }
|
||||
@@ -20,7 +21,13 @@ class AdAlert < ApplicationRecord
|
||||
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)
|
||||
# Matched on an installed component: the AD applies to that component;
|
||||
# otherwise to the airframe.
|
||||
if component && component.aircraft_id == aircraft_id
|
||||
ad.components << component unless ad.components.include?(component)
|
||||
else
|
||||
ad.aircraft << aircraft unless ad.aircraft.include?(aircraft)
|
||||
end
|
||||
update!(status: "tracked", airworthiness_directive: ad)
|
||||
ad
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user