Skip to content

Commit

Permalink
fix: change role to mapper to create new entity, gen 5 digit osm id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujanadh committed Mar 3, 2025
1 parent 27c7b2c commit 561b2f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/backend/app/db/postgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import json
import logging
import random
from datetime import datetime, timezone
from io import BytesIO
from random import getrandbits
Expand Down Expand Up @@ -378,7 +379,7 @@ def add_required_geojson_properties(
else:
# Random id
# NOTE 32-bit int is max supported by standard postgres Integer
random_id = getrandbits(30)
random_id = random.randint(20000, 29999)
feature["id"] = f"{random_id}"
properties["osm_id"] = random_id

Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,12 @@ async def add_additional_entity_list(
@router.post("/{project_id}/create-entity")
async def add_new_entity(
db: Annotated[Connection, Depends(db_conn)],
project_user_dict: Annotated[ProjectUserDict, Depends(project_manager)],
current_user: Annotated[ProjectUserDict, Depends(mapper)],
geojson: Dict[str, Any],
):
"""Create an Entity for the project in ODK."""
try:
project = project_user_dict.get("project")
project = current_user.get("project")
project_odk_id = project.odkid
project_odk_creds = project.odk_credentials

Expand Down

0 comments on commit 561b2f0

Please sign in to comment.