Skip to content

Commit

Permalink
build(profilesdao): remove useless Profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ch-liuzhide committed Dec 4, 2024
1 parent af2706e commit 328e84d
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions server/core/dao/profilesDAO.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
from core.dao.BaseDAO import BaseDAO
from supabase.client import Client

from core.models.profiles import Profiles
from petercat_utils.db.client.supabase import get_client

Check failure on line 4 in server/core/dao/profilesDAO.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F401)

core/dao/profilesDAO.py:4:34: F401 `core.models.profiles.Profiles` imported but unused


class ProfilesDAO(BaseDAO):
client: Client

def __init__(self):
super().__init__()
self.client = get_client()

def get_agreement_status(self, user_id: str):

resp = self.client.table("profiles")\
.select("agreement_accepted") \
.eq("id", user_id) \
.execute()
agreement_accepted = resp.data[0]
return agreement_accepted

def accept_agreement(self, user_id: str):
try:
response = self.client.table("profiles").update({"agreement_accepted": True}).match({"id": user_id}).execute()

if not response.data:
return False, {"message": "User does not exist, accept failed."}
return response.data[0]
except Exception as e:
print("Error: ", e)
return False, {"message": "Profile Update failed"}

client: Client

def __init__(self):
super().__init__()
self.client = get_client()

def get_agreement_status(self, user_id: str):

resp = (
self.client.table("profiles")
.select("agreement_accepted")
.eq("id", user_id)
.execute()
)
agreement_accepted = resp.data[0]
return agreement_accepted

def accept_agreement(self, user_id: str):
try:
response = (
self.client.table("profiles")
.update({"agreement_accepted": True})
.match({"id": user_id})
.execute()
)

if not response.data:
return False, {"message": "User does not exist, accept failed."}
return response.data[0]
except Exception as e:
print("Error: ", e)
return False, {"message": "Profile Update failed"}

0 comments on commit 328e84d

Please sign in to comment.