diff --git a/alembic/versions/163f6213d3f_remove_unused_fields_from_takeoff_.py b/alembic/versions/163f6213d3f_remove_unused_fields_from_takeoff_.py new file mode 100644 index 0000000..efef5e4 --- /dev/null +++ b/alembic/versions/163f6213d3f_remove_unused_fields_from_takeoff_.py @@ -0,0 +1,26 @@ +"""remove unused fields from takeoff_landing + +Revision ID: 163f6213d3f +Revises: 258a3f6bbdc +Create Date: 2016-06-03 20:05:20.749369 + +""" + +# revision identifiers, used by Alembic. +revision = '163f6213d3f' +down_revision = '258a3f6bbdc' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.drop_column('takeoff_landing', 'altitude') + op.drop_column('takeoff_landing', 'ground_speed') + + +def downgrade(): + op.add_column('takeoff_landing', sa.Column('altitude', sa.Integer)) + op.add_column('takeoff_landing', sa.Column('ground_speed', sa.Float)) diff --git a/ogn/collect/logbook.py b/ogn/collect/logbook.py index 4d2ccb1..2593e2e 100644 --- a/ogn/collect/logbook.py +++ b/ogn/collect/logbook.py @@ -98,8 +98,6 @@ def compute_takeoff_and_landing(): takeoff_landing_query = app.session.query( sq2.c.timestamp, sq2.c.track, - sq2.c.ground_speed, - sq2.c.altitude, sq2.c.is_takeoff, sq2.c.device_id, Airport.id) \ @@ -110,8 +108,6 @@ def compute_takeoff_and_landing(): # ... and save them ins = insert(TakeoffLanding).from_select((TakeoffLanding.timestamp, TakeoffLanding.track, - TakeoffLanding.ground_speed, - TakeoffLanding.altitude, TakeoffLanding.is_takeoff, TakeoffLanding.device_id, TakeoffLanding.airport_id), diff --git a/ogn/model/takeoff_landing.py b/ogn/model/takeoff_landing.py index 61e33e0..8842ac8 100644 --- a/ogn/model/takeoff_landing.py +++ b/ogn/model/takeoff_landing.py @@ -1,9 +1,7 @@ -from sqlalchemy import Boolean, Column, Float, Integer, DateTime, ForeignKey +from sqlalchemy import Boolean, Column, Integer, DateTime, ForeignKey from sqlalchemy.orm import relationship -from geoalchemy2.shape import to_shape from .base import Base -from .geo import Location class TakeoffLanding(Base): @@ -11,11 +9,8 @@ class TakeoffLanding(Base): id = Column(Integer, primary_key=True) - altitude = Column(Integer) timestamp = Column(DateTime, index=True) track = Column(Integer) - ground_speed = Column(Float) - is_takeoff = Column(Boolean) # Relations @@ -24,11 +19,3 @@ class TakeoffLanding(Base): device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True) device = relationship('Device', foreign_keys=[device_id]) - - @property - def location(self): - if self.location_wkt is None: - return None - - coords = to_shape(self.location_wkt) - return Location(lat=coords.y, lon=coords.x)