diff --git a/alembic/versions/258a3f6bbdc_add_aircraft_type_to_device.py b/alembic/versions/258a3f6bbdc_add_aircraft_type_to_device.py new file mode 100644 index 0000000..853858e --- /dev/null +++ b/alembic/versions/258a3f6bbdc_add_aircraft_type_to_device.py @@ -0,0 +1,28 @@ +"""add aircraft_type to device + +Revision ID: 258a3f6bbdc +Revises: 7585491482 +Create Date: 2016-05-25 20:16:57.990249 + +""" + +# revision identifiers, used by Alembic. +revision = '258a3f6bbdc' +down_revision = '7585491482' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('device', sa.Column('aircraft_type', sa.Integer)) + op.create_index('ix_device_aircraft_type', 'device', ['aircraft_type']) + op.create_index('ix_aircraft_beacon_aircraft_type', 'aircraft_beacon', ['aircraft_type']) + + +def downgrade(): + op.drop_index('ix_aircraft_beacon_aircraft_type', 'aircraft_beacon') + op.drop_index('ix_device_aircraft_type', 'device') + op.drop_column('device', 'aircraft_type') diff --git a/ogn/model/aircraft_beacon.py b/ogn/model/aircraft_beacon.py index 45da0fd..4796ee3 100644 --- a/ogn/model/aircraft_beacon.py +++ b/ogn/model/aircraft_beacon.py @@ -9,7 +9,7 @@ class AircraftBeacon(Beacon): # Flarm specific data address_type = Column(SmallInteger) - aircraft_type = Column(SmallInteger) + aircraft_type = Column(SmallInteger, index=True) stealth = Column(Boolean) address = Column(String(6)) climb_rate = Column(Float) diff --git a/ogn/model/device.py b/ogn/model/device.py index 877b2eb..626bf3e 100644 --- a/ogn/model/device.py +++ b/ogn/model/device.py @@ -18,6 +18,7 @@ class Device(Base): frequency = Column(String) tracked = Column(Boolean) identified = Column(Boolean) + aircraft_type = Column(SmallInteger, index=True) address_origin = Column(SmallInteger) diff --git a/ogn/utils.py b/ogn/utils.py index 5ea2e86..8dc71f5 100644 --- a/ogn/utils.py +++ b/ogn/utils.py @@ -10,7 +10,7 @@ from geopy.exc import GeopyError from aerofiles.seeyou import Reader from ogn.parser.utils import feet2m -DDB_URL = "http://ddb.glidernet.org/download" +DDB_URL = "http://ddb.glidernet.org/download/?t=1" address_prefixes = {'F': 'FLR', @@ -41,6 +41,7 @@ def get_ddb(csvfile=None): device.competition = row[4] device.tracked = row[5] == 'Y' device.identified = row[6] == 'Y' + device.aircraft_type = row[7] devices.append(device)