[eval_records]
- support older diff records
This commit is contained in:
+20
-4
@@ -7,7 +7,21 @@ BASE = "results"
|
|||||||
VIN = 'WVWZZZE1ZMP010760'
|
VIN = 'WVWZZZE1ZMP010760'
|
||||||
YEAR = 2024
|
YEAR = 2024
|
||||||
MONTH = 10
|
MONTH = 10
|
||||||
DAY = ['19']
|
DAY = ['17', '18', '19', '20']
|
||||||
|
|
||||||
|
|
||||||
|
def has_diff_entries(diff):
|
||||||
|
handled = False
|
||||||
|
if "update" in diff:
|
||||||
|
handled = True
|
||||||
|
if "update_add" in diff:
|
||||||
|
handled = True
|
||||||
|
if "add" in diff:
|
||||||
|
handled = True
|
||||||
|
if "delete" in diff:
|
||||||
|
handled = True
|
||||||
|
|
||||||
|
return handled
|
||||||
|
|
||||||
|
|
||||||
class Endpoint:
|
class Endpoint:
|
||||||
@@ -92,7 +106,7 @@ path = os.path.join(BASE, VIN)
|
|||||||
path = os.path.join(path, str(YEAR))
|
path = os.path.join(path, str(YEAR))
|
||||||
path = os.path.join(path, str(MONTH))
|
path = os.path.join(path, str(MONTH))
|
||||||
|
|
||||||
day_list = os.listdir(path)
|
day_list = sorted(os.listdir(path), key=lambda f: int(f))
|
||||||
print("Days in '", path, "' :")
|
print("Days in '", path, "' :")
|
||||||
# prints all files
|
# prints all files
|
||||||
print(day_list)
|
print(day_list)
|
||||||
@@ -106,7 +120,7 @@ for day in day_list:
|
|||||||
if day not in DAY:
|
if day not in DAY:
|
||||||
continue
|
continue
|
||||||
day_path = os.path.join(month_path, day)
|
day_path = os.path.join(month_path, day)
|
||||||
file_list = os.listdir(day_path)
|
file_list = sorted(os.listdir(day_path), key=lambda f: convert(f, pattern=f"vehicle_{VIN}_%Y-%m-%dT%H-%M-%S.json"))
|
||||||
print("Files in '", day_path, "' :")
|
print("Files in '", day_path, "' :")
|
||||||
# prints all files
|
# prints all files
|
||||||
print(file_list)
|
print(file_list)
|
||||||
@@ -136,8 +150,10 @@ for day in day_list:
|
|||||||
if is_header:
|
if is_header:
|
||||||
vehicle_data = vehicle_diff
|
vehicle_data = vehicle_diff
|
||||||
else:
|
else:
|
||||||
|
if has_diff_entries(vehicle_diff):
|
||||||
vehicle_data = jay_merge_full(last, vehicle_diff)
|
vehicle_data = jay_merge_full(last, vehicle_diff)
|
||||||
|
else:
|
||||||
|
vehicle_data = jay_merge_full(last, {'update_add': vehicle_diff})
|
||||||
last = vehicle_data
|
last = vehicle_data
|
||||||
try:
|
try:
|
||||||
for end_point in end_points:
|
for end_point in end_points:
|
||||||
|
|||||||
Reference in New Issue
Block a user