collapse repetitive changes of less than 10 minutes
This commit is contained in:
parent
39304d2392
commit
ce98e5d6e5
1 changed files with 16 additions and 0 deletions
16
generate.py
16
generate.py
|
@ -180,6 +180,22 @@ def run_forever(address: str, period: int, ssid: str, output: str):
|
|||
if lease.mac not in (l.mac for l in leases):
|
||||
log.append(log_entry(ts, False, lease))
|
||||
last_seen = leases
|
||||
|
||||
collapse_thresh = timedelta(minutes=10)
|
||||
while True:
|
||||
duplicate_index = None
|
||||
for idx in range(len(log)):
|
||||
if idx + 1 == len(log):
|
||||
continue
|
||||
if log[idx].lease.mac == log[idx + 1].lease.mac and \
|
||||
not log[idx].state and log[idx + 1].state and \
|
||||
log[idx + 1].ts - log[idx].ts < collapse_thresh:
|
||||
duplicate_index = idx
|
||||
if duplicate_index is None:
|
||||
break
|
||||
log.pop(duplicate_index) # IN
|
||||
log.pop(duplicate_index) # OUT
|
||||
|
||||
log.reverse()
|
||||
|
||||
leaderboard_tmp = {}
|
||||
|
|
Loading…
Reference in a new issue