mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
AD baseline: record DRS imports and the models they covered; weekly search starts from the last import; reminders and audit check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba0455b149
commit
8bea2abf75
13 files changed
+169
-4
No files matched your search
@@ -92,13 +92,22 @@ class AdWatch
|
||||
|
||||
# Returns the new AdAlerts.
|
||||
def check!
|
||||
since = (@aircraft.ad_watch_checked_at || FIRST_LOOKBACK.ago).to_date - 7 # overlap; duplicates are skipped
|
||||
since = start_date - 7 # overlap; duplicates are skipped
|
||||
known = AirworthinessDirective.pluck(:name).to_set
|
||||
created = terms.flat_map { |term| search(term.words, since).filter_map { record(_1, term, known) } }
|
||||
@aircraft.update_column(:ad_watch_checked_at, Time.current)
|
||||
created
|
||||
end
|
||||
|
||||
# Where the search picks up: the last check; before the first one, the
|
||||
# last DRS import (the baseline, less 60 days for ADs that hadn't reached
|
||||
# DRS yet), else two years back.
|
||||
def start_date
|
||||
return @aircraft.ad_watch_checked_at.to_date if @aircraft.ad_watch_checked_at
|
||||
imported = @aircraft.drs_imports.maximum(:created_at)
|
||||
imported ? (imported - 60.days).to_date : FIRST_LOOKBACK.ago.to_date
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def record(doc, term, known)
|
||||
|
||||
@@ -29,6 +29,7 @@ class RecordsAudit
|
||||
backup.present? && backup.ok && backup.created_at > 2.days.ago,
|
||||
backup ? "#{backup.created_at.to_date}: #{backup.message}" : "Never run"),
|
||||
*offsite_items,
|
||||
drs_item,
|
||||
Item.new("procedures", "The procedures document is adopted and its details filled in", true,
|
||||
revision.present? && @policy.complete?,
|
||||
revision ? "Revision #{revision.number}, adopted #{revision.adopted_at.to_date}" : "Not adopted yet"),
|
||||
@@ -68,6 +69,12 @@ class RecordsAudit
|
||||
|
||||
private
|
||||
|
||||
def drs_item
|
||||
due = Aircraft.ordered.select { DrsImport.renewal_due?(_1) || DrsImport.missing_models(_1).any? }
|
||||
Item.new("drs", "Each aircraft's AD list was refreshed from FAA DRS in the last 12 months, for all its models", true, due.empty?,
|
||||
due.any? ? "Needs a DRS import: #{due.map(&:tail_number).join(', ')}" : "Up to date")
|
||||
end
|
||||
|
||||
def offsite_items
|
||||
return [] unless OffsiteConnection.connected?
|
||||
run = OffsiteRun.latest_backup
|
||||
|
||||
Reference in new issue
Block a user