Skip to content

Commit

Permalink
Fix in area endpoints. (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrill authored Dec 22, 2020
1 parent e441d8e commit 31a9b92
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/routers/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def create_area(new_area: AreaConfigDTO, reboot_processor: Optional[bool]
Adds a new area to the processor.
"""
config_dict = extract_config()
areas_name = [x for x in config_dict.keys() if x.startswith("Area")]
areas_name = [x for x in config_dict.keys() if x.startswith("Area_")]
areas = [map_section_from_config(x, config_dict) for x in areas_name]
if new_area.id in [area["id"] for area in areas]:
raise HTTPException(status_code=400, detail="Area already exists")
Expand Down Expand Up @@ -97,7 +97,7 @@ async def delete_area(area_id: str, reboot_processor: Optional[bool] = True):
Deletes the configuration related to the area <area_id>
"""
config_dict = extract_config()
areas_name = [x for x in config_dict.keys() if x.startswith("Area")]
areas_name = [x for x in config_dict.keys() if x.startswith("Area_")]
areas = [map_section_from_config(x, config_dict) for x in areas_name]
areas_ids = [area["id"] for area in areas]
try:
Expand Down
2 changes: 1 addition & 1 deletion api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def handle_response(response, success, status_code=status.HTTP_200_OK):

def reestructure_areas(config_dict):
"""Ensure that all [Area_0, Area_1, ...] are consecutive"""
area_names = [x for x in config_dict.keys() if x.startswith("Area")]
area_names = [x for x in config_dict.keys() if x.startswith("Area_")]
area_names.sort()
for index, area_name in enumerate(area_names):
if f"Area_{index}" != area_name:
Expand Down

0 comments on commit 31a9b92

Please sign in to comment.