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:
rickyandClaude Opus 5.5 committed 2026-11-13 21:04:41 -05:00
1 parent e939d29deb
commit bff6a05173
25 files changed
+34 -178

No files matched your search

@@ -1,16 +0,0 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
set_current_user || reject_unauthorized_connection
end
private
def set_current_user
if session = Session.find_by(id: cookies.signed[:session_id])
self.current_user = session.user
end
end
end
end
-5
View File
@@ -21,11 +21,6 @@ module ApplicationHelper
title: Airworthiness::DISCLAIMER)
end
def airworthiness_dot(status)
color = { "RED" => "bg-red-500", "LIMITED" => "bg-sky-500", "ORANGE" => "bg-amber-400", "GREEN" => "bg-emerald-500" }[status.status]
tag.span(class: "inline-block h-3 w-3 rounded-full #{color}", title: status.label)
end
# Badge class (or text class) for one airworthiness issue.
def issue_badge_class(issue) = "badge-#{AIRWORTHINESS_COLORS[issue.severity]}"
@@ -6,8 +6,6 @@ const LABELS = { system: "System", light: "Light", dark: "Dark" }
// Light / dark / follow-the-OS theme toggle. The choice is kept in
// localStorage; the layout's inline script applies it before first paint.
export default class extends Controller {
static targets = ["button"]
connect() {
this.media = window.matchMedia("(prefers-color-scheme: dark)")
this.onSystemChange = () => { if (this.choice === "system") this.apply() }
-6
View File
@@ -30,12 +30,6 @@ class AirworthinessDirective < ApplicationRecord
find_by("upper(replace(name, ' ', '')) = ?", normalize_number(number).delete(" "))
end
def self.applicable_to(aircraft)
direct = joins(:aircraft).where(aircraft: { id: aircraft.id }).select(:id)
via_component = joins(:components).where(components: { aircraft_id: aircraft.id }).select(:id)
where(id: direct).or(where(id: via_component))
end
def to_s = name
# [url, label] for this AD's document, when we have its link (DRS Excel
-1
View File
@@ -1,5 +1,4 @@
class BackupRun < ApplicationRecord
scope :latest_first, -> { order(created_at: :desc) }
def self.latest = latest_first.first
def self.last_good = where(ok: true).latest_first.first
end
@@ -15,6 +15,15 @@ module SharedRecordHistory
before_destroy { linked_aircraft_ids.each { |id| history!(id, "destroy", attributes.except(*IGNORED)) } }
end
class_methods do
# Records that apply to the aircraft directly, or to one of its components.
def applicable_to(aircraft)
direct = joins(:aircraft).where(aircraft: { id: aircraft.id }).select(:id)
via_component = joins(:components).where(components: { aircraft_id: aircraft.id }).select(:id)
where(id: direct).or(where(id: via_component))
end
end
# Aircraft this record applies to, directly or through a component.
def linked_aircraft_ids = (aircraft_ids + components.map(&:aircraft_id)).compact.uniq
-1
View File
@@ -26,7 +26,6 @@ class EntrySignature < ApplicationRecord
def imported? = origin.present?
def certificate_label = UserCertificate::SHORT_LABELS.fetch(certificate_kind, certificate_kind)
def short_id = content_digest.first(12)
def compute_seal
payload = [ logbook_entry_id, user_id, signer_name, certificate_kind, certificate_number, statement,
-10
View File
@@ -28,15 +28,7 @@ class InspectionType < ApplicationRecord
scope :ordered, -> { order(:name) }
# Applies to the aircraft directly, or to one of its components.
def self.applicable_to(aircraft)
direct = joins(:aircraft).where(aircraft: { id: aircraft.id }).select(:id)
via_component = joins(:components).where(components: { aircraft_id: aircraft.id }).select(:id)
where(id: direct).or(where(id: via_component))
end
def to_s = name
def effect_label = EFFECTS[effect]
def limitation = LIMITATIONS[effect]
def advisory? = effect == "advisory"
@@ -46,8 +38,6 @@ class InspectionType < ApplicationRecord
InspectionRecord.for_aircraft(aircraft).where(inspection_type_id: [ id, *satisfied_by.ids ])
end
def latest_record_for(aircraft) = records_for(aircraft).recent_first.first
def due_rule
{ hours: recurring_hours.to_f, months: recurring_months, days: recurring_days } if recurring?
end
-9
View File
@@ -33,13 +33,4 @@ module Sso
ENV["APP_URL"].presence&.chomp("/") ||
"#{ENV.fetch('FORCE_SSL', 'true') == 'true' ? 'https' : 'http'}://#{ENV.fetch('APP_HOST', 'localhost:3000')}"
end
# Origin of the provider, for the CSP form-action list (the sign-in POST
# redirects there).
def issuer_origin
uri = URI.parse(ENV["OIDC_ISSUER"].to_s)
uri.host && "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
rescue URI::InvalidURIError
nil
end
end
+2 -2
View File
@@ -3,14 +3,14 @@
class SystemInfo
KEY_GEMS = %w[
puma thruster propshaft importmap-rails turbo-rails stimulus-rails tailwindcss-rails tailwindcss-ruby
solid_queue solid_cache solid_cable sqlite3 chartkick commonmarker anthropic
solid_queue solid_cache sqlite3 chartkick commonmarker anthropic
omniauth omniauth_openid_connect rubyzip roo pdf-reader bcrypt
].freeze
# Where the source lives; APP_REPOSITORY_URL overrides it for a fork.
REPOSITORY_URL = ENV["APP_REPOSITORY_URL"].presence || "https://github.com/rickbarrette/simple-aircraft-manager-rails"
DATABASES = { "Main" => :primary, "Cache" => :cache, "Jobs" => :queue, "Cable" => :cable }.freeze
DATABASES = { "Main" => :primary, "Cache" => :cache, "Jobs" => :queue }.freeze
# The release version, YYYY.MM.N (the repository's VERSION file).
def version
-1
View File
@@ -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
View File
@@ -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)
-1
View File
@@ -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.
+1 -1
View File
@@ -1,5 +1,5 @@
<%# Cycles System → Light → Dark. Icons are swapped by theme_controller.js. %>
<button type="button" data-controller="theme" data-action="theme#cycle" data-theme-target="button"
<button type="button" data-controller="theme" data-action="theme#cycle"
class="rounded p-1 text-white/80 hover:bg-white/10 hover:text-white" title="Theme: System" aria-label="Theme: System">
<svg data-theme-icon="system" class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg>
<svg data-theme-icon="light" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>