Skip to content

Commit

Permalink
fix: issues on project summaries with no centroids
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadh committed Mar 18, 2024
1 parent 3770e29 commit f1abdee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class ProjectSummary(BaseModel):
priority: ProjectPriority = ProjectPriority.MEDIUM
priority_str: str = priority.name
title: Optional[str] = None
centroid: list[float]
centroid: Optional[list[float]] = None
location_str: Optional[str] = None
description: Optional[str] = None
total_tasks: Optional[int] = None
Expand All @@ -253,9 +253,11 @@ def from_db_project(
) -> "ProjectSummary":
"""Generate model from database obj."""
priority = project.priority
centroid_point = read_wkb(project.centroid)
# NOTE format x,y (lon,lat) required for GeoJSON
centroid_coords = [centroid_point.x, centroid_point.y]
centroid_coords = []
if project.centroid:
centroid_point = read_wkb(project.centroid)
# NOTE format x,y (lon,lat) required for GeoJSON
centroid_coords = [centroid_point.x, centroid_point.y]

return cls(
id=project.id,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/home/ProjectListMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ProjectListMap = () => {
},
geometry: {
type: 'Point',
coordinates: project.centroid,
coordinates: project.centroid || [],
},
})),
};
Expand Down

0 comments on commit f1abdee

Please sign in to comment.