feature/reliability_stat
Cizz22 11 months ago
parent 3a122cabff
commit de73056ca9

@ -165,27 +165,29 @@ async def get_corrective_cost_time_chart(
for item in data["data"]
}
# Initialize all months in the range with 0
monthly_data = {}
current_date = start_date.replace(day=1)
while current_date <= end_date:
monthly_data[current_date] = 0
monthly_data[current_date] = float('inf') # Start with infinity to find minimum
# Move to next month
if current_date.month == 12:
current_date = datetime.datetime(current_date.year + 1, 1, 1)
else:
current_date = datetime.datetime(current_date.year, current_date.month + 1, 1)
# Get the last day's value for each month
# Get the minimum value for each month
for date in data_dict.keys():
month_key = datetime.datetime(date.year, date.month, 1)
if month_key in monthly_data and data_dict[date] is not None:
# Update only if the value is higher (to get the last day's value)
monthly_data[month_key] = max(monthly_data[month_key], data_dict[date])
# Update only if the value is lower (to get the minimum value)
monthly_data[month_key] = min(monthly_data[month_key], data_dict[date])
# Convert to list maintaining chronological order
complete_data = []
for month in sorted(monthly_data.keys()):
# Replace any remaining infinity values with 0 or another appropriate default
if monthly_data[month] == float('inf'):
monthly_data[month] = 0
complete_data.append(monthly_data[month])
# Convert to numpy array

Loading…
Cancel
Save