Z.Flights (Portico/Z v0.1.0)

Airport and Airline database functions.

We store a list of airlines and airports so that we can use them in various apps, most notably in GENE for the arrival/departure form airline / airport lookup functions.

Link to this section Summary

Functions

Returns an %Ecto.Changeset{} for tracking airline changes.

Returns an %Ecto.Changeset{} for tracking airport changes.

Creates a airline.

Creates a airport.

Create new or update existing airline.

Create new or update existing airport.

Deletes a airline.

Deletes a airport.

Gets a single airline, using the OpenFlights ID

Gets a single airport, using the OpenFlights ID

Returns the list of airlines.

Returns the list of airports.

Search among airlines, by name or IATA/ICAO code.

Search among airports, by name or IATA/ICAO code

Sync airlines in the Repo using data from OpenFlights

Sync airports in the Repo using data from OpenFlights

Updates a airline.

Updates a airport.

Link to this section Functions

Link to this function

change_airline(airline, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking airline changes.

Examples

iex> change_airline(airline)
%Ecto.Changeset{data: %Airline{}}
Link to this function

change_airport(airport, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking airport changes.

Examples

iex> change_airport(airport)
%Ecto.Changeset{data: %Airport{}}
Link to this function

create_airline(attrs \\ %{})

Creates a airline.

Examples

iex> create_airline(%{field: value})
{:ok, %Airline{}}

iex> create_airline(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_airport(attrs \\ %{})

Creates a airport.

Examples

iex> create_airport(%{field: value})
{:ok, %Airport{}}

iex> create_airport(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_airline(openflights_id, attrs \\ %{})

Create new or update existing airline.

Matches on openflights_id.

Examples

iex> create_or_update_airport(123, %{field: value})
{:ok, %Airport{}}
Link to this function

create_or_update_airport(openflights_id, attrs)

Create new or update existing airport.

Matches on openflights_id.

Examples

iex> create_or_update_airport(123, %{field: value})
{:ok, %Airport{}}
Link to this function

delete_airline(airline)

Deletes a airline.

Examples

iex> delete_airline(airline)
{:ok, %Airline{}}

iex> delete_airline(airline)
{:error, %Ecto.Changeset{}}
Link to this function

delete_airport(airport)

Deletes a airport.

Examples

iex> delete_airport(airport)
{:ok, %Airport{}}

iex> delete_airport(airport)
{:error, %Ecto.Changeset{}}
Link to this function

get_airline(id)

Gets a single airline, using the OpenFlights ID

Returns nil if none are found.

Examples

iex> get_airline(123)
%Airline{}

iex> get_airline(456)
nil
Link to this function

get_airport(id)

Gets a single airport, using the OpenFlights ID

Returns nil if none are found.

Examples

iex> get_airport(123)
%Airport{}

iex> get_airport(456)
nil
Link to this function

list_airlines()

Returns the list of airlines.

Examples

iex> list_airlines()
[%Airline{}, ...]
Link to this function

list_airports()

Returns the list of airports.

Examples

iex> list_airports()
[%Airport{}, ...]
Link to this function

search_airlines(value)

Search among airlines, by name or IATA/ICAO code.

Name will be "fuzzy-matched" based on a trigram search - see Utility.EctoQuery for more.

ICAO / IATA codes will only match if 100% equal.

Examples

iex> search_airlines("AA")
[%Z.Flights.Airline{}, ...]
Link to this function

search_airports(value)

Search among airports, by name or IATA/ICAO code

Name will be "fuzzy-matched" based on a trigram search - see Utility.EctoQuery for more.

ICAO / IATA codes will only match if 100% equal.

Examples

iex> search_airports("BOS")
[%Z.Flights.Airport{}, ...]
Link to this function

sync_airlines()

Sync airlines in the Repo using data from OpenFlights

Link to this function

sync_airports()

Sync airports in the Repo using data from OpenFlights

Link to this function

update_airline(airline, attrs)

Updates a airline.

Examples

iex> update_airline(airline, %{field: new_value})
{:ok, %Airline{}}

iex> update_airline(airline, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_airport(airport, attrs)

Updates a airport.

Examples

iex> update_airport(airport, %{field: new_value})
{:ok, %Airport{}}

iex> update_airport(airport, %{field: bad_value})
{:error, %Ecto.Changeset{}}