Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapper to create new entity, gen 5 digit osm id #28

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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