VioletWizard commited on
Commit
ee4ea0d
·
unverified ·
1 Parent(s): 48c103d

Update db.py

Browse files
Files changed (1) hide show
  1. db.py +9 -2
db.py CHANGED
@@ -118,7 +118,14 @@ def upsert_topic_room(supabase: Client, room_name, title, mode, entry_code):
118
 
119
  def fetch_room_entry_code(supabase: Client, room_name):
120
  try:
121
- res = supabase.table("topic").select("entry_code").eq("room_name", room_name).execute()
 
 
 
 
 
 
 
122
  return res.data[0]["entry_code"] if res and res.data else ""
123
  except Exception as e:
124
  if _is_undefined_column_error(e, "entry_code"):
@@ -131,7 +138,7 @@ def fetch_room_entry_code(supabase: Client, room_name):
131
 
132
  def fetch_topic_data(supabase: Client, room_name):
133
  res = execute_query(
134
- supabase.table("topic").select("title, mode").eq("room_name", room_name),
135
  fail_message="주제 조회 실패",
136
  )
137
  return res.data[0] if res and res.data else {}
 
118
 
119
  def fetch_room_entry_code(supabase: Client, room_name):
120
  try:
121
+ res = (
122
+ supabase.table("topic")
123
+ .select("entry_code")
124
+ .eq("room_name", room_name)
125
+ .order("id", desc=True)
126
+ .limit(1)
127
+ .execute()
128
+ )
129
  return res.data[0]["entry_code"] if res and res.data else ""
130
  except Exception as e:
131
  if _is_undefined_column_error(e, "entry_code"):
 
138
 
139
  def fetch_topic_data(supabase: Client, room_name):
140
  res = execute_query(
141
+ supabase.table("topic").select("title, mode").eq("room_name", room_name).order("id", desc=True).limit(1),
142
  fail_message="주제 조회 실패",
143
  )
144
  return res.data[0] if res and res.data else {}