Create device only if error_count == 0

pull/68/head
Konstantin Gründger 2017-12-03 20:49:30 +01:00
rodzic bc2c70d345
commit e527531d00
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -95,7 +95,7 @@ def update_devices():
.subquery()
missing_devices_query = session.query(distinct(AircraftBeacon.address)) \
.filter(AircraftBeacon.device_id == null()) \
.filter(and_(AircraftBeacon.device_id == null(), AircraftBeacon.error_count == 0)) \
.filter(~AircraftBeacon.address.in_(available_devices))
ins = insert(Device).from_select([Device.address], missing_devices_query)
@ -129,7 +129,7 @@ def update_receivers():
res = session.execute(ins)
insert_count = res.rowcount
# Update missing or changed values, update_receivers them and set country code to None if location changed
# Update missing or changed values, update them and set country code to None if location changed
new_values_range = session.query(ReceiverBeacon.name,
func.min(ReceiverBeacon.timestamp).label('firstseen'),
func.max(ReceiverBeacon.timestamp).label('lastseen')) \