@@ -148,10 +148,17 @@ def get_select_311_data(event_ids="", event_date=""):
148148 "RethinkAI-API-Key" : Config .RETHINKAI_API_KEY ,
149149 }
150150 if event_ids :
151- response = requests .post (f"{ Config .API_BASE_URL } /data/query?request=311_summary&category=all&stream=False&app_version={ Config .APP_VERSION } &output_type=csv" , headers = headers , json = {"event_ids" : event_ids })
151+ response = requests .post (
152+ f"{ Config .API_BASE_URL } /data/query?request=311_summary&category=all&stream=False&app_version={ Config .APP_VERSION } &output_type=csv" ,
153+ headers = headers ,
154+ json = {"event_ids" : event_ids },
155+ )
152156
153157 elif event_date :
154- response = requests .get (f"{ Config .API_BASE_URL } /data/query?request=311_summary&category=all&stream=True&app_version={ Config .APP_VERSION } &date={ event_date } &output_type=csv" )
158+ response = requests .get (
159+ f"{ Config .API_BASE_URL } /data/query?request=311_summary&category=all&stream=False&app_version={ Config .APP_VERSION } &date={ event_date } &output_type=csv" ,
160+ headers = headers ,
161+ )
155162
156163 response .raise_for_status ()
157164 return response .text
@@ -640,7 +647,7 @@ def get_chat_response(prompt: str, structured_response: bool = False):
640647 container.style.backgroundColor = `rgba(${r},${g},${b},0.1)`;
641648 container.style.padding = '0.5em';
642649 container.style.borderRadius = '4px';
643- container.style.marginBottom = '0.5em ';
650+ container.style.marginBottom = '1em ';
644651 });
645652 }
646653 // ─────────────────────────────────────────────────────────────
@@ -659,7 +666,7 @@ def get_chat_response(prompt: str, structured_response: bool = False):
659666 [State ("current-date-store" , "data" )],
660667)
661668
662- # — at the very bottom of your app.py, after your other callbacks —
669+ # — at the very bottom of your app.py, after your other callbacks —
663670
664671app .clientside_callback (
665672 """
@@ -722,7 +729,7 @@ def get_chat_response(prompt: str, structured_response: bool = False):
722729 """ ,
723730 Output ("loading-output" , "children" , allow_duplicate = True ),
724731 Input ("category-pie-chart" , "clickData" ),
725- prevent_initial_call = True
732+ prevent_initial_call = True ,
726733)
727734
728735app .clientside_callback (
@@ -734,11 +741,12 @@ def get_chat_response(prompt: str, structured_response: bool = False):
734741 return '';
735742 }
736743 """ ,
737- Output (' dummy-output' , ' children' , allow_duplicate = True ),
738- Input (' active-tab-store' , ' data' ),
739- prevent_initial_call = ' initial_duplicate'
744+ Output (" dummy-output" , " children" , allow_duplicate = True ),
745+ Input (" active-tab-store" , " data" ),
746+ prevent_initial_call = " initial_duplicate" ,
740747)
741748
749+
742750@app .callback (Output ("slider-value-display" , "children" ), Input ("date-slider-value" , "children" ))
743751def update_slider_display (date_value ):
744752 return date_value
@@ -1239,27 +1247,21 @@ def update_shot_count(selected, date_str):
12391247 count = df_month [df_month ["cell" ].isin (hex_ids )].shape [0 ]
12401248 return count
12411249
1250+
12421251@callback (
12431252 Output ("area-homicide-count-store" , "data" ),
12441253 [
12451254 Input ("selected-hexbins-store" , "data" ),
1246- Input ("current-date-store" , "data" ),
1255+ Input ("current-date-store" , "data" ),
12471256 ],
12481257)
12491258def update_homicide_count (selected , date_str ):
12501259 year , month = date_string_to_year_month (date_str )
12511260 ts = pd .Timestamp (f"{ year } -{ month :02d} " )
1252- df_month = df_hom_shot_matched [
1253- df_hom_shot_matched ["date" ]
1254- .dt .to_period ("M" )
1255- .dt .to_timestamp () == ts
1256- ].copy ()
1261+ df_month = df_hom_shot_matched [df_hom_shot_matched ["date" ].dt .to_period ("M" ).dt .to_timestamp () == ts ].copy ()
12571262
12581263 # build the H3 cells column via list comprehension
1259- df_month ["cell" ] = [
1260- h3 .latlng_to_cell (lat , lon , 10 )
1261- for lat , lon in zip (df_month ["latitude" ], df_month ["longitude" ])
1262- ]
1264+ df_month ["cell" ] = [h3 .latlng_to_cell (lat , lon , 10 ) for lat , lon in zip (df_month ["latitude" ], df_month ["longitude" ])]
12631265
12641266 hex_ids = selected .get ("selected_hexbins" , [])
12651267 if hex_ids :
@@ -1298,51 +1300,49 @@ def render_category_pie(counts):
12981300@callback (
12991301 Output ("shots-count-display" , "children" ),
13001302 [
1301- Input ("area-shot-count-store" , "data" ),
1302- Input ("area-homicide-count-store" ,"data" ),
1303+ Input ("area-shot-count-store" , "data" ),
1304+ Input ("area-homicide-count-store" , "data" ),
13031305 ],
13041306)
13051307def render_counts (shots_count , homicides_count ):
1306- return html .Div ([
1307- # Shots fired pill
1308- html .Div ([
1309- html .Span ("•" , style = {
1310- "color" : "#701238" ,
1311- "fontSize" : "20px" ,
1312- "marginRight" : "4px" ,
1313- }),
1314- html .Span (f"{ shots_count } " , style = {"fontWeight" : "600" }),
1315- html .Span (" Shots Fired" , style = {"marginLeft" : "4px" })
1316- ], style = {
1317- "display" : "flex" ,
1318- "alignItems" : "center" ,
1319- "backgroundColor" : "rgba(112,39,56,0.1)" ,
1320- "padding" : "4px 8px" ,
1321- "borderRadius" : "12px"
1322- }),
1323-
1324- # Homicides pill
1325- html .Div ([
1326- html .Span ("•" , style = {
1327- "color" : "#000" ,
1328- "fontSize" : "30px" ,
1329- "marginRight" : "4px" ,
1330- }),
1331- html .Span (f"{ homicides_count } " , style = {"fontWeight" : "600" }),
1332- html .Span (" Homicides" , style = {"marginLeft" : "4px" })
1333- ], style = {
1334- "display" : "flex" ,
1335- "alignItems" : "center" ,
1336- "backgroundColor" : "rgba(0,0,0,0.1)" ,
1337- "padding" : "4px 8px" ,
1338- "borderRadius" : "12px"
1339- }),
1340- ], style = {
1341- "display" : "flex" ,
1342- "gap" : "1rem" ,
1343- "marginTop" : "0.5rem" ,
1344- "fontSize" : "14px"
1345- })
1308+ return html .Div (
1309+ [
1310+ # Shots fired pill
1311+ html .Div (
1312+ [
1313+ html .Span (
1314+ "•" ,
1315+ style = {
1316+ "color" : "#701238" ,
1317+ "fontSize" : "20px" ,
1318+ "marginRight" : "4px" ,
1319+ },
1320+ ),
1321+ html .Span (f"{ shots_count } " , style = {"fontWeight" : "600" }),
1322+ html .Span (" Shots Fired" , style = {"marginLeft" : "4px" }),
1323+ ],
1324+ style = {"display" : "flex" , "alignItems" : "center" , "backgroundColor" : "rgba(112,39,56,0.1)" , "padding" : "4px 8px" , "borderRadius" : "12px" },
1325+ ),
1326+ # Homicides pill
1327+ html .Div (
1328+ [
1329+ html .Span (
1330+ "•" ,
1331+ style = {
1332+ "color" : "#000" ,
1333+ "fontSize" : "30px" ,
1334+ "marginRight" : "4px" ,
1335+ },
1336+ ),
1337+ html .Span (f"{ homicides_count } " , style = {"fontWeight" : "600" }),
1338+ html .Span (" Homicides" , style = {"marginLeft" : "4px" }),
1339+ ],
1340+ style = {"display" : "flex" , "alignItems" : "center" , "backgroundColor" : "rgba(0,0,0,0.1)" , "padding" : "4px 8px" , "borderRadius" : "12px" },
1341+ ),
1342+ ],
1343+ style = {"display" : "flex" , "gap" : "1rem" , "marginTop" : "0.5rem" , "fontSize" : "14px" },
1344+ )
1345+
13461346
13471347server = app .server
13481348
0 commit comments