mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Remove orphaned code and unused Solid Cable; simplify compliance status
- Delete methods nothing calls: BackupRun.last_good, EntrySignature#short_id, Sso#issuer_origin, InspectionType#effect_label and #latest_record_for, ApplicationHelper#airworthiness_dot, Airworthiness::Status#can_fly? and FlightStats#shortest_flight (tests now check red? / longest_flight) - Routes: sessions and passwords limited to the actions that exist - Theme toggle: drop the unused button target - Action Cable was never used (no broadcasts or streams): async adapter in production, solid_cable gem, cable database and app/channels removed - Empty system test setup removed with capybara and selenium-webdriver - Compliance: one due_result helper for overdue / due soon; inspections use next_due for the date, as ADs do - applicable_to moved into SharedRecordHistory (was identical in ADs and inspection types) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e939d29deb
commit
bff6a05173
25 files changed
+34
-178
No files matched your search
@@ -27,7 +27,6 @@ class Airworthiness
|
||||
def limited? = status == LIMITED
|
||||
def orange? = status == ORANGE
|
||||
def green? = status == GREEN
|
||||
def can_fly? = !red?
|
||||
def red_issues = issues.select { |i| i.severity == RED }
|
||||
def limitations = issues.filter_map(&:limitation).uniq
|
||||
|
||||
|
||||
+12
-49
@@ -38,31 +38,9 @@ module Compliance
|
||||
return Result.new(rank: OVERDUE) unless compliance
|
||||
return Result.new(rank: COMPLIANT) if compliance.closed?
|
||||
|
||||
rank = COMPLIANT
|
||||
result = Result.new
|
||||
|
||||
due_date = next_due(ad.due_rule, date: compliance.date_complied, hours: nil)[:date] if ad.recurring? && ad.recurring_calendar?
|
||||
due_hours = compliance.next_due_at_time.to_d
|
||||
if due_hours > 0
|
||||
result.next_due_hours = due_hours
|
||||
if current_hours >= due_hours
|
||||
rank = OVERDUE
|
||||
elsif current_hours + Airworthiness::HOURS_WARNING >= due_hours
|
||||
rank = [ rank, DUE_SOON ].max
|
||||
end
|
||||
end
|
||||
|
||||
if ad.recurring? && ad.recurring_calendar?
|
||||
due = next_due(ad.due_rule, date: compliance.date_complied, hours: nil)[:date]
|
||||
result.next_due_date = due
|
||||
if today > due
|
||||
rank = OVERDUE
|
||||
elsif today + Airworthiness::DAYS_WARNING >= due
|
||||
rank = [ rank, DUE_SOON ].max
|
||||
end
|
||||
end
|
||||
|
||||
result.rank = rank
|
||||
result
|
||||
due_result(due_date, (due_hours if due_hours.positive?), current_hours, today)
|
||||
end
|
||||
|
||||
# `records` are those that count for the type (InspectionType#records_for).
|
||||
@@ -77,32 +55,17 @@ module Compliance
|
||||
return Result.new(rank: OVERDUE) unless last_record
|
||||
return Result.new(rank: COMPLIANT) unless type.recurring?
|
||||
|
||||
rank = COMPLIANT
|
||||
result = Result.new
|
||||
due_date = next_due(type.due_rule, date: last_record.date, hours: nil)[:date]
|
||||
due_result(due_date, next_due_hours(type, records), current_hours, today)
|
||||
end
|
||||
|
||||
if type.recurring_months.positive? || type.recurring_days.positive?
|
||||
due = last_record.date
|
||||
due = end_of_month_after(due, type.recurring_months) if type.recurring_months.positive?
|
||||
due += type.recurring_days.days if type.recurring_days.positive?
|
||||
result.next_due_date = due
|
||||
if today > due
|
||||
rank = OVERDUE
|
||||
elsif today + Airworthiness::DAYS_WARNING >= due
|
||||
rank = [ rank, DUE_SOON ].max
|
||||
end
|
||||
end
|
||||
|
||||
if (due_hours = next_due_hours(type, records))
|
||||
result.next_due_hours = due_hours
|
||||
if current_hours >= due_hours
|
||||
rank = OVERDUE
|
||||
elsif current_hours + Airworthiness::HOURS_WARNING >= due_hours
|
||||
rank = [ rank, DUE_SOON ].max
|
||||
end
|
||||
end
|
||||
|
||||
result.rank = rank
|
||||
result
|
||||
# Overdue once the date has passed or the hours are reached; due soon
|
||||
# within the warning window of either.
|
||||
def due_result(due_date, due_hours, current_hours, today)
|
||||
overdue = (due_date && today > due_date) || (due_hours && current_hours >= due_hours)
|
||||
soon = (due_date && today + Airworthiness::DAYS_WARNING >= due_date) ||
|
||||
(due_hours && current_hours + Airworthiness::HOURS_WARNING >= due_hours)
|
||||
Result.new(rank: overdue ? OVERDUE : (soon ? DUE_SOON : COMPLIANT), next_due_date: due_date, next_due_hours: due_hours)
|
||||
end
|
||||
|
||||
def next_due_hours(type, records)
|
||||
|
||||
@@ -24,7 +24,6 @@ class FlightStats
|
||||
def total_fuel = @fuel.sum { _2.to_f }.round(1)
|
||||
|
||||
def average_flight = count.zero? ? nil : (total_flight / count).round(1)
|
||||
def shortest_flight = @flights.map { flight_hours(_1) }.min&.round(1)
|
||||
def longest_flight = @flights.map { flight_hours(_1) }.max&.round(1)
|
||||
|
||||
# Gallons per tach hour over all fuel records.
|
||||
|
||||
Reference in new issue
Block a user