Skip to content

Commit

Permalink
fix materialized view refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez committed Dec 4, 2024
1 parent 3a45595 commit a2cb3f9
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ async def _update_feed(
)

logging.info(
f"Feed ID: {id} attempting to update with the following request: {update_request_feed}"
f"Feed ID: {update_request_feed.id} attempting to update with the following request: "
f"{update_request_feed}"
)
impl_class = (
UpdateRequestGtfsFeedImpl
Expand All @@ -150,17 +151,23 @@ async def _update_feed(
else update_request_feed.operational_status_action
)
session.add(feed)
refresh_materialized_view(session, t_feedsearch.name)
session.commit()
# Refresh the materialized view has to be done after the commit
refresh_materialized_view(session, t_feedsearch.name)
logging.info(
f"Feed ID: {id} updated successfully with the following changes: {diff.values()}"
f"Feed ID: {update_request_feed.id} updated successfully with the following changes: "
f"{diff.values()}"
)
return Response(status_code=200)
else:
logging.info(f"No changes detected for feed ID: {id}")
logging.info(
f"No changes detected for feed ID: {update_request_feed.id}"
)
return Response(status_code=204)
except Exception as e:
logging.error(f"Failed to update feed ID: {id}. Error: {e}")
logging.error(
f"Failed to update feed ID: {update_request_feed.id}. Error: {e}"
)
if isinstance(e, HTTPException):
raise e
raise HTTPException(status_code=500, detail=f"Internal server error: {e}")
Expand Down

0 comments on commit a2cb3f9

Please sign in to comment.