Skip to content

Commit

Permalink
Merge pull request #423 from LACMTA/dev
Browse files Browse the repository at this point in the history
refactor: [data] hard coded metro_api schema
  • Loading branch information
albertkun authored Nov 29, 2023
2 parents d11a6b1 + 5c1aacb commit 0476300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data-loading-service/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def set_db_schema():

class Config:
BASE_URL = os.environ.get('BASE_URL')
TARGET_DB_SCHEMA = set_db_schema()
TARGET_DB_SCHEMA = 'metro_api'
API_DB_URI = os.environ.get('API_DB_URI')
SECRET_KEY = os.environ.get('HASH_KEY')
ALGORITHM = os.environ.get('HASHING_ALGORITHM')
Expand Down
7 changes: 5 additions & 2 deletions fastapi/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ async def validation_exception_handler(request, err):
def to_geojson(data):
features = []
for item in data:
# Check if trip_id is None before trying to access it
if item.trip_id is None:
continue # skip this item
# Create a Point from the 'geometry' coordinates
geometry = Point(item['geometry']['coordinates'])
geometry = Point((item.geometry.longitude, item.geometry.latitude))
# Exclude the 'geometry' key from the properties
properties = {key: item[key] for key in item if key != 'geometry'}
properties = {key: getattr(item, key) for key in dir(item) if not key.startswith('_') and key != 'geometry'}
feature = Feature(geometry=geometry, properties=properties)
features.append(feature)
feature_collection = FeatureCollection(features)
Expand Down

0 comments on commit 0476300

Please sign in to comment.