1
0
Fork 0
Browse Source

add fix to stop duplicating entries in find_readings_with_lights_on.

The function was originally looping through the set of readings for a
particular time-stamp. If there was more than one reading above 39, it
would append that particular time-stamp every time the if-statement
was true -- as it looped through each reading for said time-stamp.

This change adds a break and a variable to track if the time-stamp
should be added to the list -- after it has broke out of the
if-block.
stable
Craig Oates 3 years ago
parent
commit
c73f5b2d25
  1. 8
      src/services/data_services.py

8
src/services/data_services.py

@ -36,9 +36,15 @@ def find_flickers(selected_readings, all_readings):
def find_readings_with_lights_on(flicker_entries):
filtered_readings = list()
add_to_list = False
for time, reading in flicker_entries.items():
for item in reading:
val = int(item)
if (val > 39):
filtered_readings.append( (time, reading) )
add_to_list = True
break
else:
add_to_list = False
if (add_to_list == True):
filtered_readings.append( (time, reading) )
return filtered_readings