From 8649aab313716955f114a4738e1038937b6b595a Mon Sep 17 00:00:00 2001 From: Fruittips Date: Mon, 27 Nov 2023 14:54:12 +0800 Subject: [PATCH] update supabase with default r_value and fire_prob --- lambda/lambda_function.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lambda/lambda_function.py b/lambda/lambda_function.py index f499b3f..e456aea 100644 --- a/lambda/lambda_function.py +++ b/lambda/lambda_function.py @@ -43,6 +43,19 @@ def lambda_handler(event, context): # if less than 25 records, dont calculate r value and return default fire probability else: + try: + supabase.table('firecloud') \ + .update({ + "r_value": r_value, + "fire_probability": fire_probability, + }) \ + .eq('id', rowId) \ + .execute() + except Exception as e: + print(f"Error updating row in supabase: {e}") + + + return json.dumps({ 'statusCode': 200, 'body': json.dumps({ @@ -56,13 +69,13 @@ def lambda_handler(event, context): # TODO: update row in supabase table with r_value and fire_probability try: - data, count = supabase.table('firecloud') \ - .update({ - "r_value": r_value, - "fire_probability": fire_probability, - }) \ - .eq('id', rowId) \ - .execute() + supabase.table('firecloud') \ + .update({ + "r_value": r_value, + "fire_probability": fire_probability, + }) \ + .eq('id', rowId) \ + .execute() except Exception as e: print(f"Error updating row in supabase: {e}")