Spaces:
Sleeping
Sleeping
Update models.py
Browse files
models.py
CHANGED
|
@@ -236,7 +236,7 @@ def add_ques_llm(theme, question, options, correct_option, difficulty):
|
|
| 236 |
logging.error("Invalid theme provided: %s", theme)
|
| 237 |
return None
|
| 238 |
|
| 239 |
-
theme_bank = theme_bank_result[
|
| 240 |
user_id_creator = get_jwt_identity()
|
| 241 |
|
| 242 |
question_json = json.dumps({
|
|
@@ -246,7 +246,7 @@ def add_ques_llm(theme, question, options, correct_option, difficulty):
|
|
| 246 |
|
| 247 |
check_query = f"SELECT COUNT(*) FROM {theme_bank} WHERE question_by_llm = %s"
|
| 248 |
cursor.execute(check_query, (question_json,))
|
| 249 |
-
is_duplicate = cursor.fetchone()[
|
| 250 |
|
| 251 |
if is_duplicate:
|
| 252 |
logging.warning("Duplicate question detected for theme %s: %s", theme, question)
|
|
@@ -729,7 +729,7 @@ def add_theme_if_not_exists(theme):
|
|
| 729 |
|
| 730 |
theme_check_query = "SELECT COUNT(*) FROM themes WHERE theme = %s"
|
| 731 |
cursor.execute(theme_check_query, (theme,))
|
| 732 |
-
theme_exists = cursor.fetchone()[
|
| 733 |
|
| 734 |
|
| 735 |
if theme_exists == 0:
|
|
|
|
| 236 |
logging.error("Invalid theme provided: %s", theme)
|
| 237 |
return None
|
| 238 |
|
| 239 |
+
theme_bank = theme_bank_result["theme_bank"]
|
| 240 |
user_id_creator = get_jwt_identity()
|
| 241 |
|
| 242 |
question_json = json.dumps({
|
|
|
|
| 246 |
|
| 247 |
check_query = f"SELECT COUNT(*) FROM {theme_bank} WHERE question_by_llm = %s"
|
| 248 |
cursor.execute(check_query, (question_json,))
|
| 249 |
+
is_duplicate = cursor.fetchone()["COUNT(*)"] > 0
|
| 250 |
|
| 251 |
if is_duplicate:
|
| 252 |
logging.warning("Duplicate question detected for theme %s: %s", theme, question)
|
|
|
|
| 729 |
|
| 730 |
theme_check_query = "SELECT COUNT(*) FROM themes WHERE theme = %s"
|
| 731 |
cursor.execute(theme_check_query, (theme,))
|
| 732 |
+
theme_exists = cursor.fetchone()["COUNT(*)"]
|
| 733 |
|
| 734 |
|
| 735 |
if theme_exists == 0:
|