2016-01-05 23:23:45 +00:00
|
|
|
from ogn.commands.dbutils import session
|
2016-06-24 06:03:22 +00:00
|
|
|
from ogn.model import Device, AircraftType
|
2016-06-26 15:59:43 +00:00
|
|
|
from sqlalchemy import func
|
2015-12-09 02:37:25 +00:00
|
|
|
|
|
|
|
from manager import Manager
|
|
|
|
manager = Manager()
|
|
|
|
|
|
|
|
|
2016-06-24 06:03:22 +00:00
|
|
|
@manager.command
|
|
|
|
def aircraft_type_stats():
|
|
|
|
"""Show stats about aircraft types used by devices."""
|
|
|
|
aircraft_type_query = session.query(Device.aircraft_type,
|
2016-06-26 15:59:43 +00:00
|
|
|
func.count(Device.id)) \
|
|
|
|
.group_by(Device.aircraft_type) \
|
|
|
|
.order_by(func.count(Device.id).desc())
|
2016-06-24 06:03:22 +00:00
|
|
|
print("--- Aircraft types ---")
|
|
|
|
for [aircraft_type, count] in aircraft_type_query.all():
|
|
|
|
at = AircraftType(aircraft_type)
|
|
|
|
print("{}: {}".format(at.name(), count))
|
2015-12-09 02:37:25 +00:00
|
|
|
|
|
|
|
|
2016-06-24 06:03:22 +00:00
|
|
|
@manager.command
|
|
|
|
def stealth_stats():
|
|
|
|
"""Show stats about stealth flag set by devices."""
|
|
|
|
stealth_query = session.query(Device.stealth,
|
|
|
|
func.count(Device.id)) \
|
2016-06-26 15:59:43 +00:00
|
|
|
.group_by(Device.stealth) \
|
|
|
|
.order_by(func.count(Device.id).desc())
|
2016-06-24 06:03:22 +00:00
|
|
|
print("--- Stealth ---")
|
|
|
|
for [is_stealth, count] in stealth_query.all():
|
|
|
|
print("{}: {}".format(is_stealth, count))
|
2015-12-09 02:37:25 +00:00
|
|
|
|
|
|
|
|
2016-06-24 06:03:22 +00:00
|
|
|
@manager.command
|
|
|
|
def software_stats():
|
|
|
|
"""Show stats about software version used by devices."""
|
|
|
|
software_query = session.query(Device.software_version,
|
2016-06-26 15:59:43 +00:00
|
|
|
func.count(Device.id)) \
|
|
|
|
.group_by(Device.software_version) \
|
|
|
|
.order_by(func.count(Device.id).desc())
|
2016-06-24 06:03:22 +00:00
|
|
|
print("--- Software version ---")
|
|
|
|
for [software_version, count] in software_query.all():
|
|
|
|
print("{}: {}".format(software_version, count))
|
2015-12-09 02:37:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
@manager.command
|
2016-06-24 06:03:22 +00:00
|
|
|
def hardware_stats():
|
|
|
|
"""Show stats about hardware version used by devices."""
|
|
|
|
hardware_query = session.query(Device.hardware_version,
|
2016-06-26 15:59:43 +00:00
|
|
|
func.count(Device.id)) \
|
|
|
|
.group_by(Device.hardware_version) \
|
|
|
|
.order_by(func.count(Device.id).desc())
|
2016-06-24 06:03:22 +00:00
|
|
|
print("\n--- Hardware version ---")
|
|
|
|
for [hardware_version, count] in hardware_query.all():
|
|
|
|
print("{}: {}".format(hardware_version, count))
|