Skip to content

Commit

Permalink
fix postgis version issue
Browse files Browse the repository at this point in the history
  • Loading branch information
the-infinity committed Oct 27, 2023
1 parent c62103c commit 54ae053
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions webapp/models/parking_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ParkingSite(BaseModel):
public_url: Mapped[Optional[str]] = mapped_column(String(4096), nullable=True)
address: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
description: Mapped[Optional[str]] = mapped_column(String(4096), nullable=True)
type: Mapped[ParkingSiteType] = mapped_column(SqlalchemyEnum(ParkingSiteType), nullable=True)
type: Mapped[Optional[ParkingSiteType]] = mapped_column(SqlalchemyEnum(ParkingSiteType), nullable=True)

max_stay: Mapped[Optional[int]] = mapped_column(Integer(), nullable=True)
has_lighting: Mapped[Optional[bool]] = mapped_column(Boolean(), nullable=True)
Expand Down Expand Up @@ -143,7 +143,9 @@ def to_dict(self, fields: Optional[list[str]] = None, ignore: Optional[list[str]
'realtime_capacity_bus',
]

return super().to_dict(fields, ignore)
result = super().to_dict(fields, ignore)

return {key: value for key, value in result.items() if value is not None}

@hybrid_property
def park_and_ride_type(self) -> Mapped[Optional[list[ParkAndRideType]]]:
Expand Down
4 changes: 2 additions & 2 deletions webapp/repositories/parking_site_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def _filter_by_search_query(self, query: Query, search_query: Optional[BaseSearc

if hasattr(search_query, 'location') and hasattr(search_query, 'radius') and search_query.location:
query = query.filter(
func.ST_Distance_Sphere(
func.ST_DistanceSphere(
ParkingSite.geometry,
func.ST_GeomFromText(f'POINT({float(search_query.location[1])} {float(search_query.location[0])})'),
)
< search_query.radius * 10000
< search_query.radius * 1000
)

return query
Expand Down

0 comments on commit 54ae053

Please sign in to comment.