Blackstone oil analysis, .sam.zip export/import, AI logbook transcription

- Oil analysis: Blackstone PDF import (20 elements, oil properties, universal
  averages), results stored per element, oil type, "leave out of trends",
  the original app's statuses; AvLab fixes (multi-line comments, unrelated
  labels no longer steal values). Existing records migrate.
- Aircraft archives in the original app's .sam.zip format (schema v2): export
  from Access & Sharing, background import from the Fleet page, rake tasks.
  Archives move both ways between this app and the original.
- Scanned logbook pages (images or PDFs) upload as a document; with
  ANTHROPIC_API_KEY set, Claude transcribes them into logbook entries.
- Fix: deleting a component or aircraft failed when AD compliances or
  inspection records pointed at a component.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-06 21:05:19 -05:00
1 parent 2d068e1a63
commit 1c6c2f88c0
54 files changed
+2794 -286

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
# Aircraft archives (.sam.zip): a whole aircraft's records and files in one ZIP,
# in the format of the original Simple Aircraft Manager (manifest schema v2), so
# archives move both ways between this app and the original.
#
# manifest.json all records, with archive-local IDs linking them
# attachments/… pictures, document pages, squawk files, track logs…
#
# Records carry a few extra keys for data only this app has (all squawk
# attachments, engine monitor files, oil report PDFs and lab averages, newer AD
# fields). The original ignores keys it doesn't know inside records, but rejects
# unknown top-level keys, so none are added there.
module AircraftArchive
class Error < StandardError; end
SCHEMA_VERSION = 2
TOP_LEVEL_KEYS = %w[
schema_version exported_at source_instance aircraft component_types components document_collections
documents document_images logbook_entries squawks inspection_types inspection_records ads ad_compliances
consumable_records major_records notes oil_analysis_reports flight_logs features
].freeze
OPTIONAL_KEYS = %w[features].freeze # and flight_logs before schema v2
MANIFEST_MAX_BYTES = 50.megabytes
FILE_MAX_BYTES = 512.megabytes
ARCHIVE_MAX_BYTES = 10.gigabytes # uncompressed
MAX_RATIO = 100 # compression ratio above this looks like a zip bomb
# Leading bytes per extension; text formats have none to check.
MAGIC = {
"jpg" => [ "\xFF\xD8\xFF".b ], "jpeg" => [ "\xFF\xD8\xFF".b ], "png" => [ "\x89PNG\r\n\x1A\n".b ],
"gif" => [ "GIF8".b ], "webp" => [ "RIFF".b ], "bmp" => [ "BM".b ], "tif" => [ "II*\x00".b, "MM\x00*".b ],
"tiff" => [ "II*\x00".b, "MM\x00*".b ], "pdf" => [ "%PDF-".b ]
}.freeze
TEXT_EXTENSIONS = %w[txt csv gpx kml xml].freeze
EXTENSIONS = (MAGIC.keys + TEXT_EXTENSIONS).freeze
def self.extension(path) = File.extname(path.to_s).delete(".").downcase
def self.content_matches?(data, ext)
return EXTENSIONS.include?(ext) unless MAGIC.key?(ext)
MAGIC[ext].any? { data.byteslice(0, _1.bytesize) == _1 }
end
end