Skip to content

Commit a1f290e

Browse files
authored
Merge pull request #19 from ryan-roche/dev
Fix getAllBuildings endpoint, moved to /buildings
2 parents bd6b450 + 224807c commit a1f290e

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

app/main.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class RouteResponseModel(BaseModel):
9494
app = FastAPI(
9595
title="GopherMaps API",
9696
summary="REST API for the GopherMaps Project",
97-
version="1.2",
97+
version="1.2.1",
9898
contact={
9999
"name": "Ryan Roche",
100100
"url": "https://socialcoding.net"
@@ -266,19 +266,16 @@ async def get_areas() -> list[AreaModel]:
266266
return areas
267267

268268

269-
@app.get("/buildings/{area}", tags=["Buildings"], operation_id="getBuildingsForArea")
270-
async def get_buildings_by_area(
271-
area: AreaName = Path(..., description="The label name of the requested area")
272-
) -> List[BuildingEntryModel]:
269+
@app.get("/buildings", tags=["Buildings"], operation_id="getAllBuildings")
270+
async def get_all_buildings() -> list[BuildingEntryModel]:
273271
"""
274-
Get all the buildings in a given area
272+
Retrieves information for ALL Buildings
275273
"""
276274
with driver.session() as session:
277275
query = """
278-
MATCH (n:BuildingKey {area: $areaName}) RETURN n
276+
MATCH (n:BuildingKey) RETURN n
279277
"""
280-
parameters = {"areaName": area}
281-
result = session.run(query, parameters)
278+
result = session.run(query)
282279

283280
results: List[Dict[str, Any]] = result.data()
284281

@@ -287,18 +284,21 @@ async def get_buildings_by_area(
287284
BuildingEntryModel(**record['n']) for record in results
288285
]
289286

290-
return building_entries
287+
return building_entries
291288

292-
@app.get("/buildings/all", tags=["Buildings"], operation_id="getAllBuildings")
293-
async def get_all_buildings() -> list[BuildingEntryModel]:
289+
@app.get("/buildings/{area}", tags=["Buildings"], operation_id="getBuildingsForArea")
290+
async def get_buildings_by_area(
291+
area: AreaName = Path(..., description="The label name of the requested area")
292+
) -> List[BuildingEntryModel]:
294293
"""
295-
Retrieves information for ALL Buildings
294+
Get all the buildings in a given area
296295
"""
297296
with driver.session() as session:
298297
query = """
299-
MATCH (n:BuildingKey) RETURN n
298+
MATCH (n:BuildingKey {area: $areaName}) RETURN n
300299
"""
301-
result = session.run(query)
300+
parameters = {"areaName": area}
301+
result = session.run(query, parameters)
302302

303303
results: List[Dict[str, Any]] = result.data()
304304

@@ -307,7 +307,7 @@ async def get_all_buildings() -> list[BuildingEntryModel]:
307307
BuildingEntryModel(**record['n']) for record in results
308308
]
309309

310-
return building_entries
310+
return building_entries
311311

312312
@app.get("/destinations/{building}", tags=["Routing"], operation_id="getDestinationsForBuilding")
313313
async def get_destinations_for_building(

0 commit comments

Comments
 (0)