Closed erithmetic closed 12 years ago
I like this idea. The reason we haven't done this before is it will require developing and maintaining a BTS to ICAO airline code dictionary. There are about 200 BTS codes used by flight segments that don't have a matching ICAO code in our airlines table, and a further 1,100 BTS codes that aren't used but appear in the airlines table with not matching ICAO code. It's possible that some of these airlines simply don't have an ICAO code.
OK, maybe we can add a unique identifier to each airline and relate flight_segments on airline_id. The id is looked up on data_mining using either BTS or ICAO code.
@rossmeissl thoughts on creating our own custom airline id? If we can it would be nice to stick to ICAO code but that may not be feasible if there are indeed airlines with a BTS code but no ICAO code.
-1 on creating a custom airline ID. My opinion is that we should take the time to enable the "complex" relation here (i.e. allow for both relation-via-BTS and relation-via-ICAO)
I've added a relationship to another project, wondering if I should move it into Earth:
class FlightSegment
def airline
if airline_bts_code
Airline.where(:bts_code => airline_bts_code).first
else
Airline.where(:icao_code => airline_icao_code).first
end
end
end
It's not a true ActiveRecord::Relation, but it does the trick. Found it impossible to write a belongs_to for this case.
@derek looks good - go ahead and add
Currently there are two fields that point to an airline, depending on what source is used. There is FlightSegment#airline_bts_code and FlightSegment#airline_icao_code. If a data source uses BTS codes (like T100), then we fill in airline_bts_code.
This becomes problematic when relating FlightSegment to Airline - it's super difficult to have some sort of compound relation that chooses an airline based on whether BTS code or ICAO code is given.
I propose that on data_miner import processing, we only assign an airline_icao_code, and choose it based on what's given - look up the appropriate airline ICAO code based on BTS or ICAO. This will simplify apps written to use FlightSegment directly from Earth. Thus, airline_bts_code will be removed from FlightSegment.