diff --git a/functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py b/functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py index 73d0628c6..611193b51 100644 --- a/functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py +++ b/functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py @@ -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 @@ -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}")