Make sure ints stay ints and floats stay floats

Specific history data patterns would sometimes lead to some of the stats switching between int and float type even if they were always whole numbers. This should ensure that doesn't happen.

I think this will fix #12, but will likely require deleting all the spacex.starlink.user_terminal.ping_stats data points from the database before the type conflict failure will go away.
This commit is contained in:
sparky8512 2021-01-11 22:04:39 -08:00
parent 3528542410
commit fcbcbf4ef7

View file

@ -185,13 +185,13 @@ def history_ping_stats(parse_samples, verbose=False):
# index to next data sample after the newest one. # index to next data sample after the newest one.
offset = current % samples offset = current % samples
tot = 0 tot = 0.0
count_full_drop = 0 count_full_drop = 0
count_unsched = 0 count_unsched = 0
total_unsched_drop = 0 total_unsched_drop = 0.0
count_full_unsched = 0 count_full_unsched = 0
count_obstruct = 0 count_obstruct = 0
total_obstruct_drop = 0 total_obstruct_drop = 0.0
count_full_obstruct = 0 count_full_obstruct = 0
second_runs = [0] * 60 second_runs = [0] * 60
@ -211,9 +211,10 @@ def history_ping_stats(parse_samples, verbose=False):
for i in sample_range: for i in sample_range:
d = history.pop_ping_drop_rate[i] d = history.pop_ping_drop_rate[i]
tot += d
if d >= 1: if d >= 1:
count_full_drop += d # just in case...
d = 1
count_full_drop += 1
run_length += 1 run_length += 1
elif run_length > 0: elif run_length > 0:
if init_run_length is None: if init_run_length is None:
@ -238,7 +239,8 @@ def history_ping_stats(parse_samples, verbose=False):
count_obstruct += 1 count_obstruct += 1
total_obstruct_drop += d total_obstruct_drop += d
if d >= 1: if d >= 1:
count_full_obstruct += d count_full_obstruct += 1
tot += d
# If the entire sample set is one big drop run, it will be both initial # If the entire sample set is one big drop run, it will be both initial
# fragment (continued from prior sample range) and final one (continued # fragment (continued from prior sample range) and final one (continued