From 1040f86f0e6df0d9c37c3f236f13b80505e68ee8 Mon Sep 17 00:00:00 2001 From: Ayyub I Date: Mon, 13 Nov 2023 19:44:25 -0600 Subject: [PATCH] mod: update supabase func now updates card_type --- packages/googlecloud/functions/getanswer/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/googlecloud/functions/getanswer/main.py b/packages/googlecloud/functions/getanswer/main.py index 529ba43d..0850dea5 100644 --- a/packages/googlecloud/functions/getanswer/main.py +++ b/packages/googlecloud/functions/getanswer/main.py @@ -22,9 +22,9 @@ supabase_key = os.environ.get("SUPABASE_SERVICE_KEY_STAGING") supabase = create_client(supabase_url, supabase_key) -def update_supabase(response, query): +def update_supabase(response, query, response_type): # Assume you have a table named 'answers' with a column named 'answer' - response = supabase.table('cards').insert({'title': query, 'responses': response}).execute() + response = supabase.table('cards').insert({'title': query, 'responses': response, 'card_type': response_type}).execute() if response.error: logging.error(f"Failed to update Supabase: {response.error}") @@ -74,7 +74,7 @@ def getanswer(request): answer = answer_query(query, response_type, voting_roll_df, db_general, db_in_depth) # Update Supabase instead of returning the answer to the client - update_supabase(answer, query) + update_supabase(answer, query, response_type) end = time.time() elapsed = math.ceil(end - start)