Skip to content

Commit b15eeef

Browse files
committed
add missing task name in call
1 parent 452ceb0 commit b15eeef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

api/src/shared/common/gcp_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import json
12
import logging
23
import os
34
from google.cloud import tasks_v2
45
from google.protobuf.timestamp_pb2 import Timestamp
56

7+
REFRESH_VIEW_TASK_EXECUTOR_BODY = json.dumps(
8+
{"task": "refresh_materialized_view", "payload": {"dry_run": False}}
9+
).encode()
10+
611

712
def create_refresh_materialized_view_task():
813
"""
@@ -40,19 +45,18 @@ def create_refresh_materialized_view_task():
4045
gcp_region = os.getenv("GCP_REGION")
4146
environment_name = os.getenv("ENVIRONMENT")
4247
url = f"https://{gcp_region}-" f"{project}.cloudfunctions.net/" f"tasks_executor-{environment_name}"
43-
4448
# Enqueue the task
4549
try:
4650
create_http_task_with_name(
4751
client=tasks_v2.CloudTasksClient(),
48-
body=b"",
52+
body=REFRESH_VIEW_TASK_EXECUTOR_BODY,
4953
url=url,
5054
project_id=project,
5155
gcp_region=gcp_region,
5256
queue_name=queue,
5357
task_name=task_name,
5458
task_time=proto_time,
55-
http_method=tasks_v2.HttpMethod.GET,
59+
http_method=tasks_v2.HttpMethod.POST,
5660
)
5761
logging.info("Scheduled refresh materialized view task for %s", task_name)
5862
return {"message": "Refresh task for %s scheduled." % task_name}, 200

0 commit comments

Comments
 (0)