[31b88f42] Add staff locations and reach visualization to Heatmap Tool

This commit is contained in:
2026-03-09 13:44:15 +00:00
parent 47973445dc
commit f9e16bc8ad
3 changed files with 196 additions and 10 deletions

View File

@@ -21,6 +21,22 @@ df_storage = None
plz_column_name = None
plz_geocoord_df = None
STAFF_DATA = {
"sales": [
{"name": "Alexander Kiss", "plz": "86911"},
{"name": "Sebastian Hosbach", "plz": "44135"},
{"name": "Pierre Holein", "plz": "65428"},
{"name": "Daniel Sengstock", "plz": "24939"},
],
"technicians": [
{"name": "Merlin Kraus", "plz": "84489"},
{"name": "Bledar Haxijaj", "plz": "85570"},
{"name": "Aaron Schmelting", "plz": "44649"},
{"name": "Sergej", "plz": "97070"},
{"name": "Christoph Kadlubek", "plz": "30159"},
]
}
@app.on_event("startup")
def load_plz_data():
global plz_geocoord_df
@@ -59,6 +75,30 @@ class PlzColumnRequest(BaseModel):
def read_root():
return {"message": "Heatmap Tool Backend"}
@app.get("/api/staff-locations")
async def get_staff_locations():
global plz_geocoord_df
if plz_geocoord_df.empty:
raise HTTPException(status_code=500, detail="Geocoding data is not available on the server.")
result = {"sales": [], "technicians": []}
for category in ["sales", "technicians"]:
for person in STAFF_DATA[category]:
plz = person["plz"]
if plz in plz_geocoord_df.index:
coords = plz_geocoord_df.loc[plz]
result[category].append({
"name": person["name"],
"plz": plz,
"lat": float(coords["y"]),
"lon": float(coords["x"])
})
else:
print(f"WARNING: PLZ {plz} not found for {person['name']}")
return result
@app.post("/api/upload")
async def upload_file(file: UploadFile = File(...)):
global df_storage, plz_column_name