Skip to content

Commit

Permalink
check for None response
Browse files Browse the repository at this point in the history
  • Loading branch information
minump committed Jan 22, 2024
1 parent ad35ba7 commit d3e7ebe
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ai_ta_backend/agents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ def fetch_field_from_db(self, field: str):
"""
response = self.supabase_client.table("docker_images").select(field). \
eq("image_name", self.image_name).execute()
return response.data[0][field]
if response.data is not None:
return response.data[0][field]
else:
return None

def update_field_in_db(self, field: str, value: Any):
"""Method to update field in supabase DB.
Expand All @@ -263,7 +266,10 @@ def update_field_in_db(self, field: str, value: Any):
"""
response = self.supabase_client.table("docker_images").update({field: value}). \
eq("image_name", self.image_name).execute()
return response
if response.data is not None:
return response
else:
return None

def upsert_field_in_db(self, field, value):
"""Method to upsert field in supabase DB.
Expand All @@ -273,9 +279,11 @@ def upsert_field_in_db(self, field, value):
Returns:
APIResponse: Response from Supabase.
"""
response = self.supabase_client.table("docker_images").upsert({field: value}). \
eq("image_name", self.image_name).execute()
return response
response = self.supabase_client.table("docker_images").upsert({"image_name": self.image_name, field: value}).execute()
if response.data is not None:
return response
else:
return None

def check_and_insert_image_name(self, image_name):
"""Check if the image name exists in the Supabase table, if not, insert it and build a Docker image.
Expand Down

0 comments on commit d3e7ebe

Please sign in to comment.