Skip to content

Commit

Permalink
mod: update supabase func now updates card_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyubibrahimi committed Nov 14, 2023
1 parent 90900e8 commit 1040f86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/googlecloud/functions/getanswer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1040f86

Please sign in to comment.