Skip to content

Commit

Permalink
Merge pull request #28 from naxa-developers/fea/create-entity
Browse files Browse the repository at this point in the history
Mapper to create new entity, gen 5 digit osm id
  • Loading branch information
Sujanadh authored Mar 3, 2025
2 parents 27c7b2c + 561b2f0 commit 3dc9e77
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 3dc9e77

Please sign in to comment.