Skip to content

Commit a2cb3f9

Browse files
committed
fix materialized view refresh
1 parent 3a45595 commit a2cb3f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ async def _update_feed(
130130
)
131131

132132
logging.info(
133-
f"Feed ID: {id} attempting to update with the following request: {update_request_feed}"
133+
f"Feed ID: {update_request_feed.id} attempting to update with the following request: "
134+
f"{update_request_feed}"
134135
)
135136
impl_class = (
136137
UpdateRequestGtfsFeedImpl
@@ -150,17 +151,23 @@ async def _update_feed(
150151
else update_request_feed.operational_status_action
151152
)
152153
session.add(feed)
153-
refresh_materialized_view(session, t_feedsearch.name)
154154
session.commit()
155+
# Refresh the materialized view has to be done after the commit
156+
refresh_materialized_view(session, t_feedsearch.name)
155157
logging.info(
156-
f"Feed ID: {id} updated successfully with the following changes: {diff.values()}"
158+
f"Feed ID: {update_request_feed.id} updated successfully with the following changes: "
159+
f"{diff.values()}"
157160
)
158161
return Response(status_code=200)
159162
else:
160-
logging.info(f"No changes detected for feed ID: {id}")
163+
logging.info(
164+
f"No changes detected for feed ID: {update_request_feed.id}"
165+
)
161166
return Response(status_code=204)
162167
except Exception as e:
163-
logging.error(f"Failed to update feed ID: {id}. Error: {e}")
168+
logging.error(
169+
f"Failed to update feed ID: {update_request_feed.id}. Error: {e}"
170+
)
164171
if isinstance(e, HTTPException):
165172
raise e
166173
raise HTTPException(status_code=500, detail=f"Internal server error: {e}")

0 commit comments

Comments
 (0)