Skip to content

Commit 124b62c

Browse files
committed
direct call to refresh materialized view gcp function
1 parent 8a47536 commit 124b62c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

functions-python/reverse_geolocation/src/reverse_geolocation_processor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import flask
99
import pandas as pd
10+
import requests
1011
import shapely.geometry
1112
from geoalchemy2 import WKTElement
1213
from geoalchemy2.shape import to_shape
@@ -375,7 +376,15 @@ def extract_location_aggregates(
375376

376377
# Commit the changes to the database before refreshing the materialized view
377378
db_session.commit()
378-
refresh_materialized_view(db_session, t_feedsearch.name)
379+
380+
# Replace direct call to refresh_materialized_view with HTTP request to GCP function
381+
function_url = os.getenv("FUNCTION_URL_REFRESH_MV")
382+
if not function_url:
383+
raise ValueError("FUNCTION_URL_REFRESH_MV environment variable is not set")
384+
385+
response = requests.get(f"{function_url}/refresh-materialized-view")
386+
response.raise_for_status()
387+
logger.info("Materialized view refresh event triggered successfully.")
379388

380389

381390
@with_db_session

0 commit comments

Comments
 (0)