Fixed aircraft_beacon

remove stats
pull/78/head
Konstantin Gründger 2020-05-15 22:54:34 +02:00
rodzic a18e6aeab3
commit bb129134a8
3 zmienionych plików z 1 dodań i 133 usunięć

Wyświetl plik

@ -3,7 +3,6 @@ from .export import user_cli as export_cli
from .flights import user_cli as flights_cli
from .gateway import user_cli as gateway_cli
from .logbook import user_cli as logbook_cli
from .stats import user_cli as stats_cli
def register(app):
@ -12,4 +11,3 @@ def register(app):
app.cli.add_command(flights_cli)
app.cli.add_command(gateway_cli)
app.cli.add_command(logbook_cli)
app.cli.add_command(stats_cli)

Wyświetl plik

@ -1,130 +0,0 @@
from flask.cli import AppGroup
import click
from datetime import datetime
from tqdm import tqdm
from app.commands.database import get_database_days
from app.collect.stats import (
create_device_stats,
create_receiver_stats,
create_relation_stats,
create_country_stats,
update_qualities,
update_receivers as update_receivers_command,
update_devices as update_devices_command,
update_device_stats_jumps,
)
from app.collect.ognrange import update_entries as update_receiver_coverages
from app.model import Device
from app import db
user_cli = AppGroup("stats")
user_cli.help = "Handling of statistical data."
@user_cli.command("create")
@click.argument("start")
@click.argument("end")
def create(start, end):
"""Create DeviceStats, ReceiverStats and RelationStats."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
pbar.set_description(datetime.strftime(single_date, "%Y-%m-%d"))
result = create_device_stats(session=db.session, date=single_date)
result = update_device_stats_jumps(session=db.session, date=single_date)
result = create_receiver_stats(session=db.session, date=single_date)
result = create_relation_stats(session=db.session, date=single_date)
result = update_qualities(session=db.session, date=single_date)
@user_cli.command("create_country")
@click.argument("start")
@click.argument("end")
def create_country(start, end):
"""Create CountryStats."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
pbar.set_description(datetime.strftime(single_date, "%Y-%m-%d"))
result = create_country_stats(session=db.session, date=single_date)
@user_cli.command("update_devices_name")
def update_devices_name():
"""Update Devices name."""
device_ids = db.session.query(Device.id).all()
for device_id in tqdm(device_ids):
db.session.execute(
"update devices d set name = sq.name from ( select * from aircraft_beacons ab where ab.device_id = {} limit 1) sq where d.id = sq.device_id and d.name is null or d.name = 'ICA3D3CC4';".format(
device_id[0]
)
)
db.session.commit()
@user_cli.command("update_receivers")
def update_receivers():
"""Update receivers with data from stats."""
result = update_receivers_command(session=db.session)
print(result)
@user_cli.command("update_devices")
def update_devices():
"""Update devices with data from stats."""
result = update_devices_command(session=db.session)
print(result)
@user_cli.command("update_mgrs")
@click.argument("start")
@click.argument("end")
def update_mgrs(start, end):
"""Create location_mgrs_short."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
datestr = datetime.strftime(single_date, "%Y-%m-%d")
pbar.set_description(datestr)
for pbar2 in tqdm(["{:02d}:{:02d}".format(hh, mm) for hh in range(0, 24) for mm in range(0, 60)]):
sql = """
UPDATE aircraft_beacons
SET location_mgrs_short = left(location_mgrs, 5) || substring(location_mgrs, 6, 2) || substring(location_mgrs, 11, 2)
WHERE timestamp BETWEEN '{0} {1}:00' and '{0} {1}:59' AND location_mgrs_short IS NULL;
""".format(
datestr, pbar2
)
# print(sql)
db.session.execute(sql)
db.session.commit()
@user_cli.command("create_ognrange")
@click.argument("start")
@click.argument("end")
def create_ognrange(start=None, end=None):
"""Create receiver coverage stats for Melissas ognrange."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
pbar.set_description(datetime.strftime(single_date, "%Y-%m-%d"))
result = update_receiver_coverages(session=db.session, date=single_date)

Wyświetl plik

@ -35,7 +35,7 @@ class AircraftBeacon(Beacon):
agl = db.Column(db.Float(precision=2))
def __repr__(self):
return "<AircraftBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
return "<AircraftBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
self.address_type,
self.aircraft_type,
self.stealth,