File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -76,16 +76,11 @@ async def fetch_chart_data_with_filters(chart_filters: ChartFilters):
7676 {"status" : "success" , "filters" : chart_filters .model_dump ()}
7777 )
7878 # Sanitize the response to handle NaN and Infinity values
79- def sanitize (obj ):
80- if isinstance (obj , dict ):
81- return {k : sanitize (v ) for k , v in obj .items ()}
82- elif isinstance (obj , list ):
83- return [sanitize (v ) for v in obj ]
84- elif isinstance (obj , float ) and (math .isnan (obj ) or math .isinf (obj )):
85- return None
86- else :
87- return obj
88- response = sanitize (response )
79+ for record in response :
80+ if isinstance (record .get ("chart_value" ), list ):
81+ for item in record ["chart_value" ]:
82+ if isinstance (item .get ("value" ), float ) and (math .isnan (item ["value" ]) or math .isinf (item ["value" ])):
83+ item ["value" ] = None
8984 return JSONResponse (content = response )
9085 except Exception as e :
9186 logger .exception ("Error in fetch_chart_data_with_filters: %s" , str (e ))
You can’t perform that action at this time.
0 commit comments