ogn-python/ogn/model/receiver_stats.py

46 wiersze
1.7 KiB
Python
Czysty Zwykły widok Historia

2018-10-21 15:34:03 +00:00
from sqlalchemy import Column, Integer, SmallInteger, Date, Float, ForeignKey, DateTime, String, Index
from sqlalchemy.orm import relationship, backref
2018-01-21 20:06:27 +00:00
from geoalchemy2.types import Geometry
2017-12-12 20:46:21 +00:00
from .base import Base
class ReceiverStats(Base):
__tablename__ = "receiver_stats"
id = Column(Integer, primary_key=True)
date = Column(Date)
2018-01-21 20:06:27 +00:00
2018-09-03 17:58:35 +00:00
# Static data
2018-01-21 20:06:27 +00:00
firstseen = Column(DateTime, index=True)
lastseen = Column(DateTime, index=True)
location_wkt = Column('location', Geometry('POINT', srid=4326))
altitude = Column(Float(precision=2))
version = Column(String)
platform = Column(String)
2017-12-12 20:46:21 +00:00
2018-09-03 17:58:35 +00:00
# Statistic data
aircraft_beacon_count = Column(Integer)
aircraft_count = Column(SmallInteger)
max_distance = Column(Float)
2018-10-21 15:34:03 +00:00
quality = Column(Float(precision=2))
# Relation statistic data
quality_offset = Column(Float(precision=2))
2018-09-03 17:58:35 +00:00
# Ranking data
aircraft_beacon_count_ranking_worldwide = Column(SmallInteger)
aircraft_beacon_count_ranking_country = Column(SmallInteger)
aircraft_count_ranking_worldwide = Column(SmallInteger)
aircraft_count_ranking_country = Column(SmallInteger)
max_distance_ranking_worldwide = Column(SmallInteger)
max_distance_ranking_country = Column(SmallInteger)
2018-10-21 15:34:03 +00:00
quality_ranking_worldwide = Column(Integer)
quality_ranking_country = Column(Integer)
2018-09-03 17:58:35 +00:00
2017-12-12 20:46:21 +00:00
# Relations
receiver_id = Column(Integer, ForeignKey('receivers.id', ondelete='SET NULL'), index=True)
2018-10-21 15:34:03 +00:00
receiver = relationship('Receiver', foreign_keys=[receiver_id], backref=backref('stats', order_by='ReceiverStats.date.asc()'))
Index('ix_receiver_stats_date_receiver_id', ReceiverStats.date, ReceiverStats.receiver_id)