From 0db17b3ba6fee97c9e4a1417da1d213bdd706127 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 9 Nov 2026 21:12:28 -0500 Subject: [PATCH] AD search: make + model for the aircraft, maker + type for components, additive custom terms Tested against real Federal Register data: - aircraft searched as make + model ("Cessna" "150L"), which drops the transport-category ADs that merely contain the model string - components also searched as maker + type ("Bendix" "magneto"): appliance ADs usually name a series, not the exact model; "A/B" makers are split - propellers also searched as maker + "propeller" - custom terms add to the automatic searches (they used to replace them, silently turning off engine/component searches); a bare aircraft model is skipped since make + model covers it Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- app/services/ad_watch.rb | 47 ++++++++++++++----- .../airworthiness_directives/index.html.erb | 6 +-- docs/guide/ads.md | 2 +- test/integration/group_four_test.rb | 13 +++-- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f86b85e..7b9b769 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ To back up or move a single aircraft with all its files, use **Access & Sharing | Squawks | Four priorities. "Ground Aircraft" grounds the aircraft. Inoperative items can be deferred under 91.213(d) after confirming each condition; resolving can record the fix as a logbook entry. Attachments, reopen. | | Notes | Per-aircraft notes in Markdown, with a preview; shown on share links. | | ADs and bulletins | Shared across aircraft and applicable to the airframe or to specific components. Hour- and month-based recurrence (due at end of month), conditional and non-mandatory types, per-aircraft "not applicable" determinations, and compliance history with method of compliance and the revision complied with. | -| New ADs | Weekly search of the Federal Register for newly published ADs mentioning the aircraft model, the engine and propeller models and families, or any installed component's make and model (or your own terms); tracking one found through a component makes it apply to that component. Review each: track it as an AD or dismiss it. | +| New ADs | Weekly search of the Federal Register for newly published ADs mentioning the aircraft model, the engine and propeller models and families, or any installed component's maker, type and model (plus your own terms); tracking one found through a component makes it apply to that component. Review each: track it as an AD or dismiss it. | | AD import | Import ADs from an FAA DRS export (`.xlsx` recommended: its AD numbers link to each AD's DRS page, which the import keeps; `.csv` works without links). ADs are matched by number, so nothing is duplicated. The preview suggests Track, Not applicable or Skip for each AD, and flags superseded or non-current ADs, model mismatches, appliance or STC-only ADs, and repetitive actions. | | Inspections | Shared inspection types with hour, month, and day recurrence, plus history. Each says what overdue means (grounded, no IFR, no transponder, advisory); an annual can also count as the 100-hour, and the 100-hour's 10-hour overrun is credited (91.409(b)). One click adds the standard Part 91 set. | | Logbook | Maintenance entries with search and a link to a scanned document page. Records the signer's certificate kind and number and an inspection's result, and flags what 43.9 / 43.11 needs that's missing. Entries transcribed by Claude stay "unverified" until someone checks them against the scan. Entry templates (built-in pilot preventive maintenance per 43.3(g) and Part 43 Appendix A(c); admins add and edit their own under Admin → Logbook templates). Engine and propeller entries link the component and record its total time and time since overhaul (SMOH/SFOH/SNEW) at the entry, worked out from the entry's airframe total time; sub-components (an oil filter on the engine…) can be included with their own times. Print entries as a PDF on Avery 5163/8163 or 5164/8164 labels or half-letter/letter pages (boxed) to sign and put in the paper logbook. | diff --git a/app/services/ad_watch.rb b/app/services/ad_watch.rb index 916c536..de39ebc 100644 --- a/app/services/ad_watch.rb +++ b/app/services/ad_watch.rb @@ -24,29 +24,47 @@ class AdWatch ENGINE_OR_PROP = /engine|propell?er|\bprop\b/i - # The aircraft model; each engine and propeller model (and its family); - # and every other installed component's make and model, so ADs on - # appliances (magnetos, ELTs, radios, filters…) are found too. + # What to look for, each a few words that must all appear in the AD: + # - the aircraft make + model ("Cessna" "150L": the make keeps unrelated + # ADs that happen to contain "150L" out); + # - each engine and propeller model, and its family ("O-200A", "O-200"); + # for a propeller also its maker + "propeller"; + # - every other installed component as maker + model designator, type + + # designator, and maker + type ("Bendix" "magneto"): appliance ADs often + # name a series ("S-20") rather than the exact model. def self.default_terms(aircraft) terms = [] - terms << Term.new(aircraft.model.strip, [ aircraft.model.strip ], nil) if aircraft.model.present? + if aircraft.model.present? + model = aircraft.model.strip + terms << Term.new([ aircraft.make, model ].compact_blank.join(" "), [ maker_words(aircraft.make).first, model ].compact, nil) + end aircraft.components.in_use.includes(:component_type).order(:id).each do |c| model = c.model.to_s.strip next if model.blank? - if c.component_type&.name.to_s.match?(ENGINE_OR_PROP) + type = c.component_type&.name.to_s.strip + label = [ c.manufacturer.to_s.strip, model ].compact_blank.join(" ") + makers = maker_words(c.manufacturer) + if type.match?(ENGINE_OR_PROP) [ model, model_family(model) ].compact.each { |m| terms << Term.new(m, [ m ], c.id) } + makers.each { |mk| terms << Term.new(label, [ mk, "propeller" ], c.id) } if type.match?(/prop/i) else - label = [ c.manufacturer.to_s.strip, model ].compact_blank.join(" ") - # Maker + model, and type + model: ADs often name the maker differently - # (a successor company) but say what the part is ("magneto", "ELT"). - [ c.manufacturer.to_s.strip.split.first, c.component_type&.name.to_s.strip.split.first ].compact_blank.uniq.each do |lead| - terms << Term.new(label, ([ lead ] + designators(model)).uniq, c.id) - end + makers.each { |mk| terms << Term.new(label, [ mk ] + designators(model), c.id) } + terms << Term.new(label, [ type ] + designators(model), c.id) if type.present? + makers.each { |mk| terms << Term.new(label, [ mk, type ], c.id) } if type.present? end end terms.uniq { _1.words.map(&:downcase) } end + # The words to search a maker by: each maker in "Continental/Bendix", by its + # first word, or the whole name when that's too short to mean much ("Air Example Co"). + def self.maker_words(maker) + maker.to_s.split(%r{\s*[/,&]\s*}).map(&:strip).compact_blank.map do |name| + first = name.split.first + first.length >= 4 ? first : name + end.uniq + end + # The engine family ADs often name instead of the exact model, and that also # catches a different spelling of the suffix: "O-200A" and "O-200-A" -> "O-200", # "IO-550-N" -> "IO-550". Nil when there's no family to add. @@ -63,10 +81,13 @@ class AdWatch with_digits.any? ? with_digits : words end - # The owner's own list (comma-separated) replaces the defaults. + # The automatic searches plus the owner's own terms (comma-separated). def terms custom = @aircraft.ad_watch_terms.to_s.split(/[,;\n]/).map(&:strip).compact_blank - custom.any? ? custom.map { Term.new(_1, [ _1 ], nil) } : self.class.default_terms(@aircraft) + # The bare aircraft model is already searched with its make, which keeps + # out the many unrelated ADs that contain the same characters. + custom.reject! { _1.casecmp?(@aircraft.model.to_s.strip) } + (self.class.default_terms(@aircraft) + custom.map { Term.new(_1, [ _1 ], nil) }).uniq { _1.words.map(&:downcase) } end # Returns the new AdAlerts. diff --git a/app/views/airworthiness_directives/index.html.erb b/app/views/airworthiness_directives/index.html.erb index 84ae94a..31ae374 100644 --- a/app/views/airworthiness_directives/index.html.erb +++ b/app/views/airworthiness_directives/index.html.erb @@ -84,11 +84,11 @@ <% if owner? %> <%= form_with url: terms_aircraft_ad_alerts_path(@aircraft), method: :patch, class: "flex flex-wrap items-end gap-2 border-t border-slate-100 px-4 py-3" do %>
- <%= label_tag :ad_watch_terms, "Search terms", class: "label" %> - <%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: AdWatch.default_terms(@aircraft).map(&:label).uniq.join(", ").presence || "e.g. 172N, O-320, 1C160" %> + <%= label_tag :ad_watch_terms, "Additional search terms", class: "label" %> + <%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: "e.g. an STC or part that isn't a component" %>
<%= submit_tag "Save", class: "btn-secondary" %> -

Comma-separated model names. Left blank, the aircraft model, engine and propeller models (and their families) and every installed component’s make and model are used; a match on a component makes the tracked AD apply to that component. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.

+

Comma-separated, searched in addition to the automatic ones: the aircraft make and model, engine and propeller models (and families), and every installed component’s maker, type and model. A match on a component makes the tracked AD apply to that component. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.

<% end %> <% end %> diff --git a/docs/guide/ads.md b/docs/guide/ads.md index 8b72d14..fd703b2 100644 --- a/docs/guide/ads.md +++ b/docs/guide/ads.md @@ -10,7 +10,7 @@ The **ADs** tab lists the ADs and bulletins that apply to the aircraft or its co ## Newly published ADs -The app searches the Federal Register weekly for new ADs mentioning the aircraft model, the engine and propeller models (and their families, e.g. O-200 for an O-200A), and the make and model of every other installed component, such as magnetos, the ELT and radios (or only the terms you set). Tracking an AD found through a component makes it apply to that component. **Check now** runs it straight away. For each match, **Track** it or **Dismiss** it. Matches are only *possibly* applicable: check the AD's applicability and serial number ranges first. +The app searches the Federal Register weekly for new ADs mentioning the aircraft make and model, the engine and propeller models (and their families, e.g. O-200 for an O-200A), and every other installed component by its maker, type and model, such as magnetos, the ELT and radios. ADs often name a series rather than the exact model, so "Bendix" + "magneto" is searched as well as the model. You can add your own terms (an STC, a part that isn't a component); they're searched as well. Tracking an AD found through a component makes it apply to that component. **Check now** runs it straight away. For each match, **Track** it or **Dismiss** it. Matches are only *possibly* applicable: check the AD's applicability and serial number ranges first. ## Recording compliance diff --git a/test/integration/group_four_test.rb b/test/integration/group_four_test.rb index 3214aea..2811056 100644 --- a/test/integration/group_four_test.rb +++ b/test/integration/group_four_test.rb @@ -169,8 +169,9 @@ class GroupFourTest < ActionDispatch::IntegrationTest magneto = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Champion", model: "Slick 4301") create_component(@a, component_type: component_type("ELT"), manufacturer: "Artex", model: "345", status: "SPARE") terms = AdWatch.default_terms(@a) - assert_equal [ "172N", "Champion Slick 4301" ], terms.map(&:label).uniq # spares skipped - assert_equal [ %w[Champion 4301], %w[Magneto 4301] ], terms.drop(1).map(&:words) # maker + designator, type + designator + assert_equal [ "Cessna 172N", "Champion Slick 4301" ], terms.map(&:label).uniq # spares skipped + assert_equal %w[Cessna 172N], terms.first.words # the make keeps unrelated "172N" mentions out + assert_equal [ %w[Champion 4301], %w[Magneto 4301], %w[Champion Magneto] ], terms.drop(1).map(&:words) # maker/type + designator, maker + type assert_equal [ magneto.id ], terms.drop(1).map(&:component_id).uniq stub_request(:get, %r{federalregister}).to_return(status: 200, body: { results: [] }.to_json) @@ -188,7 +189,9 @@ class GroupFourTest < ActionDispatch::IntegrationTest test "newly published ADs are found, tracked or dismissed, and reported weekly" do create_component(@a, component_type: component_type("Engine"), model: "O-320-H2AD") - assert_equal [ "172N", "O-320-H2AD", "O-320" ], AdWatch.default_terms(@a).map(&:label) # engine family too + assert_equal [ "Cessna 172N", "O-320-H2AD", "O-320" ], AdWatch.default_terms(@a).map(&:label) # engine family too + assert_equal %w[Continental Bendix], AdWatch.maker_words("Continental/Bendix") + assert_equal [ "Air Example Co" ], AdWatch.maker_words("Air Example Co") # short first word: whole name assert_equal "O-200", AdWatch.model_family("O-200A") assert_equal "IO-550", AdWatch.model_family("IO-550-N") assert_nil AdWatch.model_family("O-200") @@ -227,8 +230,8 @@ class GroupFourTest < ActionDispatch::IntegrationTest post dismiss_aircraft_ad_alert_path(@a, other) assert_equal "dismissed", other.reload.status - patch terms_aircraft_ad_alerts_path(@a), params: { ad_watch_terms: "172, O-320" } - assert_equal [ "172", "O-320" ], AdWatch.new(@a.reload).terms.map(&:label) + patch terms_aircraft_ad_alerts_path(@a), params: { ad_watch_terms: "172, O-320, 172n" } # the bare model is skipped + assert_equal [ "Cessna 172N", "O-320-H2AD", "O-320", "172" ], AdWatch.new(@a.reload).terms.map(&:label) # added to the automatic ones stub_request(:get, %r{federalregister}).to_return(status: 503) post check_aircraft_ad_alerts_path(@a)