From 609f95ff80ddb57aeb38f1b6fb26104169208595 Mon Sep 17 00:00:00 2001 From: Sujan Adhikari <109404840+Sujanadh@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:03:58 +0545 Subject: [PATCH] fix(backend): allow empty task id and osm id for new geopoint (#1774) * fix: allow empty task id and osm id for new geopoint * fix: no need to check updatedat for submission count * fix: task_id will be populated from form so it won't be null * refactor: check if osm_id is empty str --------- Co-authored-by: sujanadh --- src/backend/app/central/central_crud.py | 6 ++++++ src/frontend/src/views/ProjectSubmissions.tsx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/app/central/central_crud.py b/src/backend/app/central/central_crud.py index 669bd2ff9..39d9fb899 100644 --- a/src/backend/app/central/central_crud.py +++ b/src/backend/app/central/central_crud.py @@ -795,6 +795,12 @@ async def get_entities_data( # Rename '__id' to 'id' flattened_dict["id"] = flattened_dict.pop("__id") + + # convert empty str osm_id to None + # when new entities are created osm_id will be empty + if flattened_dict.get("osm_id", "") == "": + flattened_dict["osm_id"] = None + all_entities.append(flattened_dict) return all_entities diff --git a/src/frontend/src/views/ProjectSubmissions.tsx b/src/frontend/src/views/ProjectSubmissions.tsx index 67abd25ad..28779f071 100644 --- a/src/frontend/src/views/ProjectSubmissions.tsx +++ b/src/frontend/src/views/ProjectSubmissions.tsx @@ -20,7 +20,7 @@ const ProjectSubmissions = () => { const state = useAppSelector((state) => state.project); const projectInfo = useAppSelector((state) => state.project.projectInfo); const entityList = useAppSelector((state) => state.project.entityOsmMap); - const updatedEntities = entityList?.filter((entity) => entity?.updated_at && entity?.status > 1); + const updatedEntities = entityList?.filter((entity) => entity?.status > 1); //Fetch project for the first time useEffect(() => {