ogn-python/ogn/model/device_stats.py

48 wiersze
1.5 KiB
Python
Czysty Zwykły widok Historia

2018-01-19 18:14:57 +00:00
from sqlalchemy import Column, Integer, Date, DateTime, Float, ForeignKey, SmallInteger, Boolean, String
2017-12-12 20:46:21 +00:00
from sqlalchemy.orm import relationship
from .base import Base
class DeviceStats(Base):
__tablename__ = "device_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-19 18:14:57 +00:00
firstseen = Column(DateTime)
lastseen = Column(DateTime)
aircraft_type = Column(SmallInteger)
stealth = Column(Boolean)
2018-01-21 20:06:27 +00:00
software_version = Column(Float(precision=2))
2018-01-19 18:14:57 +00:00
hardware_version = Column(SmallInteger)
real_address = Column(String(6))
2017-12-12 20:46:21 +00:00
2018-09-03 17:58:35 +00:00
# Statistic data
max_altitude = Column(Float(precision=2))
receiver_count = Column(SmallInteger)
aircraft_beacon_count = Column(Integer)
2018-01-21 20:06:27 +00:00
ambiguous = Column(Boolean)
2018-09-03 17:58:35 +00:00
# Ranking data
max_altitude_ranking_worldwide = Column(Integer)
max_altitude_ranking_country = Column(Integer)
receiver_count_ranking_worldwide = Column(Integer)
receiver_count_ranking_country = Column(Integer)
aircraft_beacon_count_ranking_worldwide = Column(Integer)
aircraft_beacon_count_ranking_country = Column(Integer)
2018-01-21 20:06:27 +00:00
2017-12-12 20:46:21 +00:00
# Relations
device_id = Column(Integer, ForeignKey('devices.id', ondelete='SET NULL'), index=True)
2017-12-30 09:52:47 +00:00
device = relationship('Device', foreign_keys=[device_id], backref='stats')
2017-12-13 13:08:29 +00:00
def __repr__(self):
return "<DeviceStats: %s,%s,%s,%s>" % (
self.date,
self.receiver_count,
self.aircraft_beacon_count,
self.max_altitude)