kopia lustrzana https://github.com/glidernet/ogn-python
Consistent relations and backrefs
rodzic
b1b64a3ad7
commit
cb183926b8
|
@ -59,8 +59,8 @@ def lxml(session, show_offline=False, lat_max=90, lat_min=-90, lon_max=180, lon_
|
|||
for [aircraft_beacon, device] in position_query.all():
|
||||
code = encode(device.address)
|
||||
|
||||
if len(device.informations) > 0:
|
||||
device_info = device.informations[0]
|
||||
if len(device.infos) > 0:
|
||||
device_info = device.infos[0]
|
||||
if device_info and (not device_info.tracked or not device_info.identified):
|
||||
continue
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ class AircraftBeacon(Beacon):
|
|||
|
||||
# Relations
|
||||
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'))
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id], backref='aircraft_beacons')
|
||||
|
||||
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'))
|
||||
device = relationship('Device', foreign_keys=[device_id])
|
||||
device = relationship('Device', foreign_keys=[device_id], backref='aircraft_beacons')
|
||||
|
||||
# Multi-column indices
|
||||
Index('ix_aircraft_beacon_receiver_id_receiver_name', 'receiver_id', 'receiver_name')
|
||||
|
|
|
@ -22,9 +22,6 @@ class Airport(Base):
|
|||
runway_length = Column(Integer)
|
||||
frequency = Column(Float)
|
||||
|
||||
# Relations
|
||||
takeoff_landings = relationship('TakeoffLanding')
|
||||
|
||||
def __repr__(self):
|
||||
return "<Airport %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,% s>" % (
|
||||
self.name,
|
||||
|
|
|
@ -17,10 +17,6 @@ class Device(Base):
|
|||
hardware_version = Column(SmallInteger)
|
||||
real_address = Column(String(6))
|
||||
|
||||
# Relations
|
||||
aircraft_beacons = relationship('AircraftBeacon')
|
||||
informations = relationship('DeviceInfo', backref="device")
|
||||
|
||||
def __repr__(self):
|
||||
return "<Device: %s,%s,%s,%s,%s,%s>" % (
|
||||
self.address,
|
||||
|
|
|
@ -21,6 +21,7 @@ class DeviceInfo(Base):
|
|||
|
||||
# Relations
|
||||
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True)
|
||||
device = relationship('Device', foreign_keys=[device_id], backref='infos')
|
||||
|
||||
def __repr__(self):
|
||||
return "<DeviceInfo: %s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
||||
|
|
|
@ -16,7 +16,7 @@ class DeviceStats(Base):
|
|||
|
||||
# Relations
|
||||
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], backref='stats')
|
||||
|
||||
def __repr__(self):
|
||||
return "<DeviceStats: %s,%s,%s,%s>" % (
|
||||
|
|
|
@ -22,10 +22,6 @@ class Receiver(Base):
|
|||
version = Column(String)
|
||||
platform = Column(String)
|
||||
|
||||
# Relations
|
||||
aircraft_beacons = relationship('AircraftBeacon')
|
||||
receiver_beacons = relationship('ReceiverBeacon')
|
||||
|
||||
@property
|
||||
def location(self):
|
||||
if self.location_wkt is None:
|
||||
|
|
|
@ -35,7 +35,7 @@ class ReceiverBeacon(Beacon):
|
|||
|
||||
# Relations
|
||||
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'))
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id], backref='receiver_beacons')
|
||||
|
||||
# Multi-column indices
|
||||
Index('ix_receiver_beacon_receiver_id_name', 'receiver_id', 'name')
|
||||
|
|
|
@ -17,4 +17,4 @@ class ReceiverStats(Base):
|
|||
|
||||
# Relations
|
||||
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'), index=True)
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
||||
receiver = relationship('Receiver', foreign_keys=[receiver_id], backref='stats')
|
||||
|
|
|
@ -15,7 +15,7 @@ class TakeoffLanding(Base):
|
|||
|
||||
# Relations
|
||||
airport_id = Column(Integer, ForeignKey('airport.id', ondelete='SET NULL'), index=True)
|
||||
airport = relationship('Airport', foreign_keys=[airport_id])
|
||||
airport = relationship('Airport', foreign_keys=[airport_id], backref='takeoff_landings')
|
||||
|
||||
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], backref='takeoff_landings')
|
||||
|
|
Ładowanie…
Reference in New Issue