kopia lustrzana https://github.com/glidernet/ogn-python
Remove unused fields from TakeoffLanding
rodzic
f935f0b583
commit
7464b546af
|
@ -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))
|
|
@ -98,8 +98,6 @@ def compute_takeoff_and_landing():
|
||||||
takeoff_landing_query = app.session.query(
|
takeoff_landing_query = app.session.query(
|
||||||
sq2.c.timestamp,
|
sq2.c.timestamp,
|
||||||
sq2.c.track,
|
sq2.c.track,
|
||||||
sq2.c.ground_speed,
|
|
||||||
sq2.c.altitude,
|
|
||||||
sq2.c.is_takeoff,
|
sq2.c.is_takeoff,
|
||||||
sq2.c.device_id,
|
sq2.c.device_id,
|
||||||
Airport.id) \
|
Airport.id) \
|
||||||
|
@ -110,8 +108,6 @@ def compute_takeoff_and_landing():
|
||||||
# ... and save them
|
# ... and save them
|
||||||
ins = insert(TakeoffLanding).from_select((TakeoffLanding.timestamp,
|
ins = insert(TakeoffLanding).from_select((TakeoffLanding.timestamp,
|
||||||
TakeoffLanding.track,
|
TakeoffLanding.track,
|
||||||
TakeoffLanding.ground_speed,
|
|
||||||
TakeoffLanding.altitude,
|
|
||||||
TakeoffLanding.is_takeoff,
|
TakeoffLanding.is_takeoff,
|
||||||
TakeoffLanding.device_id,
|
TakeoffLanding.device_id,
|
||||||
TakeoffLanding.airport_id),
|
TakeoffLanding.airport_id),
|
||||||
|
|
|
@ -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 sqlalchemy.orm import relationship
|
||||||
from geoalchemy2.shape import to_shape
|
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
from .geo import Location
|
|
||||||
|
|
||||||
|
|
||||||
class TakeoffLanding(Base):
|
class TakeoffLanding(Base):
|
||||||
|
@ -11,11 +9,8 @@ class TakeoffLanding(Base):
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
altitude = Column(Integer)
|
|
||||||
timestamp = Column(DateTime, index=True)
|
timestamp = Column(DateTime, index=True)
|
||||||
track = Column(Integer)
|
track = Column(Integer)
|
||||||
ground_speed = Column(Float)
|
|
||||||
|
|
||||||
is_takeoff = Column(Boolean)
|
is_takeoff = Column(Boolean)
|
||||||
|
|
||||||
# Relations
|
# Relations
|
||||||
|
@ -24,11 +19,3 @@ class TakeoffLanding(Base):
|
||||||
|
|
||||||
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True)
|
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True)
|
||||||
device = relationship('Device', foreign_keys=[device_id])
|
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)
|
|
||||||
|
|
Ładowanie…
Reference in New Issue