Cizz22 3 months ago
parent d651441a8a
commit e7581a8983

@ -89,22 +89,22 @@ async def get_overhaul_critical_parts(db_session, session_id, token):
# Filter out items without matrix data (where rbd_simulation.get() returned None) # Filter out items without matrix data (where rbd_simulation.get() returned None)
filtered_result = [item for item in base_result if item["matrix"] is not None] filtered_result = [item for item in base_result if item["matrix"] is not None]
# Sort by availability (lowest to highest) and limit to 10 # # Sort by availability (lowest to highest) and limit to 10
availability_result = sorted( # availability_result = sorted(
filtered_result, # filtered_result,
key=lambda x: x["matrix"]["availability"] # key=lambda x: x["matrix"]["availability"]
)[:10] # )[:10]
# Sort by criticality (highest to lowest) and limit to 10 # # Sort by criticality (highest to lowest) and limit to 10
criticality_result = sorted( # criticality_result = sorted(
filtered_result, # filtered_result,
key=lambda x: x["matrix"]["criticality"], # key=lambda x: x["matrix"]["criticality"],
reverse=True # reverse=True
)[:10] # )[:10]
return { return {
"availability" : availability_result, "availability" : filtered_result[:10],
"criticality": criticality_result "criticality": filtered_result[:10]
} }

Loading…
Cancel
Save