mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
AirTrail sync and export, GPS tracks, airport database with autocomplete
AirTrail (https://github.com/johanohly/AirTrail): - File export (Flights → Export for AirTrail) in AirTrail's import format, validated against its schema; same-day repeat legs get leg numbers so AirTrail's de-duplication doesn't merge them. - Automatic sync through AirTrail's REST API (Profile → AirTrail sync): per-user connection with an encrypted API key and scope check; flights are created/updated/deleted in background jobs; a full sync first links flights already in AirTrail (e.g. from a file import) instead of duplicating them; airports are resolved and cached, with manual mapping for unknown codes. - GPS tracks: GPX, KML and CSV track logs are converted to AirTrail's track format for both sync and export; the flight page shows a summary. - Aircraft ICAO type (e.g. C150) for AirTrail's aircraft type. Airport database (OurAirports, the source AirTrail uses): - Managed like AirTrail: downloaded in the background on first start, updated in place from Admin → Airports (adds, changes, removes; ids stable), with admin-managed custom airports that updates never touch. - Each airport carries AirTrail's code, so logged codes translate to AirTrail's exactly (1B9 → K1B9, 4MB → K5M3). - From/To autocomplete on new flights (airports this aircraft has used rank first); From is pre-filled with the last flight's destination; codes are normalized to uppercase. - Flights → Standardize airport codes: rewrite logged codes to the standard code, and fix codes not in the database (typos such as 0R8 → 08R are suggested). Also: admin pages grouped under an Admin dropdown menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c4803d717
commit
5bf682502b
68 files changed
+2667
-10
No files matched your search
@@ -0,0 +1,46 @@
|
||||
class CreateAirTrailSync < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
# ICAO type designator (e.g. C150), used for AirTrail's aircraft type.
|
||||
add_column :aircraft, :icao_type, :string
|
||||
|
||||
# One AirTrail account per user; flights sync to their pilot's account.
|
||||
create_table :air_trail_connections do |t|
|
||||
t.references :user, null: false, foreign_key: true, index: { unique: true }
|
||||
t.string :base_url, null: false
|
||||
t.text :api_key, null: false # encrypted
|
||||
t.boolean :enabled, null: false, default: true
|
||||
t.string :remote_user_id
|
||||
t.string :remote_username
|
||||
t.string :status # ok | error
|
||||
t.text :last_error
|
||||
t.datetime :checked_at
|
||||
t.datetime :backfilled_at
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
# Which AirTrail flight each local flight corresponds to.
|
||||
create_table :air_trail_syncs do |t|
|
||||
t.references :air_trail_connection, null: false, foreign_key: true
|
||||
t.references :flight_log, null: false, foreign_key: true
|
||||
t.integer :remote_id
|
||||
t.string :payload_digest
|
||||
t.string :status, null: false, default: "pending" # pending | synced | error
|
||||
t.text :last_error
|
||||
t.datetime :synced_at
|
||||
t.timestamps
|
||||
end
|
||||
add_index :air_trail_syncs, [ :air_trail_connection_id, :flight_log_id ], unique: true, name: "idx_air_trail_syncs_unique"
|
||||
|
||||
# Airport code → AirTrail airport id (nil = looked up, not found).
|
||||
create_table :air_trail_airports do |t|
|
||||
t.references :air_trail_connection, null: false, foreign_key: true
|
||||
t.string :code, null: false
|
||||
t.integer :remote_id
|
||||
t.string :remote_icao
|
||||
t.boolean :manual, null: false, default: false
|
||||
t.datetime :looked_up_at
|
||||
t.timestamps
|
||||
end
|
||||
add_index :air_trail_airports, [ :air_trail_connection_id, :code ], unique: true, name: "idx_air_trail_airports_unique"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
# Airport reference data (OurAirports, the source AirTrail uses) for
|
||||
# autocomplete and for translating codes to AirTrail's. The data itself is
|
||||
# downloaded on first start (AirportUpdateJob), as AirTrail does.
|
||||
class CreateAirports < ActiveRecord::Migration[8.1]
|
||||
def up
|
||||
create_table :airports do |t|
|
||||
t.string :ident, null: false
|
||||
t.string :airtrail_code, null: false
|
||||
t.string :gps_code
|
||||
t.string :local_code
|
||||
t.string :iata
|
||||
t.string :name, null: false
|
||||
t.string :kind
|
||||
t.string :municipality
|
||||
t.string :region
|
||||
t.string :country
|
||||
t.float :latitude
|
||||
t.float :longitude
|
||||
t.integer :elevation_ft
|
||||
t.timestamps
|
||||
end
|
||||
add_index :airports, :ident, unique: true
|
||||
add_index :airports, :airtrail_code
|
||||
add_index :airports, :gps_code
|
||||
add_index :airports, :local_code
|
||||
add_index :airports, :iata
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :airports
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
class AddCustomAirportsAndUpdates < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
# Airports added by an admin; never touched by OurAirports updates.
|
||||
add_column :airports, :custom, :boolean, null: false, default: false
|
||||
add_index :airports, :custom
|
||||
|
||||
# History of OurAirports updates (shown on the admin Airports page).
|
||||
create_table :airport_updates do |t|
|
||||
t.string :status, null: false, default: "queued" # queued | running | done | failed
|
||||
t.string :source_url
|
||||
t.integer :created_count, null: false, default: 0
|
||||
t.integer :updated_count, null: false, default: 0
|
||||
t.integer :removed_count, null: false, default: 0
|
||||
t.text :error
|
||||
t.references :requested_by, foreign_key: { to_table: :users, on_delete: :nullify }
|
||||
t.datetime :started_at
|
||||
t.datetime :finished_at
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user