Spaces:
Runtime error
Runtime error
Update db.py
Browse files
db.py
CHANGED
|
@@ -82,10 +82,20 @@ def topic_entry_code_column_available() -> bool:
|
|
| 82 |
return False
|
| 83 |
|
| 84 |
def fetch_room_names(supabase: Client):
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
if not res or not res.data:
|
| 90 |
return []
|
| 91 |
return [item.get("room_name", "") for item in res.data if item.get("room_name", "").strip()]
|
|
@@ -126,7 +136,7 @@ def upsert_topic_room(supabase: Client, room_name, title, mode, entry_code, crea
|
|
| 126 |
"entry_code": entry_code,
|
| 127 |
}
|
| 128 |
if created_by is not None:
|
| 129 |
-
|
| 130 |
try:
|
| 131 |
return supabase.table("topic").upsert(payload).execute()
|
| 132 |
except Exception as e:
|
|
|
|
| 82 |
return False
|
| 83 |
|
| 84 |
def fetch_room_names(supabase: Client):
|
| 85 |
+
try:
|
| 86 |
+
res = execute_query(
|
| 87 |
+
supabase.table("topic")
|
| 88 |
+
.select("room_name")
|
| 89 |
+
.neq("created_by", "")
|
| 90 |
+
.not_.is_("created_by", "null")
|
| 91 |
+
.order("room_name", desc=False),
|
| 92 |
+
fail_message="🚨 방 목록 조회 에러",
|
| 93 |
+
)
|
| 94 |
+
except Exception as e:
|
| 95 |
+
if _is_undefined_column_error(e, "created_by"):
|
| 96 |
+
logger.warning("topic.created_by 컬럼이 없어 교사 생성 방만 조회할 수 없습니다.")
|
| 97 |
+
return []
|
| 98 |
+
raise
|
| 99 |
if not res or not res.data:
|
| 100 |
return []
|
| 101 |
return [item.get("room_name", "") for item in res.data if item.get("room_name", "").strip()]
|
|
|
|
| 136 |
"entry_code": entry_code,
|
| 137 |
}
|
| 138 |
if created_by is not None:
|
| 139 |
+
payload["created_by"] = str(created_by).strip()
|
| 140 |
try:
|
| 141 |
return supabase.table("topic").upsert(payload).execute()
|
| 142 |
except Exception as e:
|