|
@@ -505,7 +505,7 @@ class QuestionDuplicateChecker:
|
|
|
|
|
|
|
|
def sync_all_from_db(self, batch_size=50, max_workers=5):
|
|
def sync_all_from_db(self, batch_size=50, max_workers=5):
|
|
|
"""同步数据库中所有题目到索引 (支持加权模式 + 批量 + 多线程)"""
|
|
"""同步数据库中所有题目到索引 (支持加权模式 + 批量 + 多线程)"""
|
|
|
- print("正在进行全量同步 (优化版 - 加权模式)...")
|
|
|
|
|
|
|
+ print("🔄 开始全量同步 (优化版 - 加权模式)...")
|
|
|
existing_ids = {m['id'] for m in self.metadata}
|
|
existing_ids = {m['id'] for m in self.metadata}
|
|
|
try:
|
|
try:
|
|
|
conn = pymysql.connect(
|
|
conn = pymysql.connect(
|
|
@@ -518,9 +518,11 @@ class QuestionDuplicateChecker:
|
|
|
cursorclass=pymysql.cursors.DictCursor
|
|
cursorclass=pymysql.cursors.DictCursor
|
|
|
)
|
|
)
|
|
|
with conn.cursor() as cursor:
|
|
with conn.cursor() as cursor:
|
|
|
|
|
+ print("📡 正在从数据库读取所有题目数据...")
|
|
|
sql = "SELECT id, stem, options, answer, solution FROM questions_tem"
|
|
sql = "SELECT id, stem, options, answer, solution FROM questions_tem"
|
|
|
cursor.execute(sql)
|
|
cursor.execute(sql)
|
|
|
all_questions = cursor.fetchall()
|
|
all_questions = cursor.fetchall()
|
|
|
|
|
+ print(f"📦 数据库加载完成,共计 {len(all_questions)} 条记录")
|
|
|
|
|
|
|
|
new_questions = [q for q in all_questions if q['id'] not in existing_ids]
|
|
new_questions = [q for q in all_questions if q['id'] not in existing_ids]
|
|
|
total_new = len(new_questions)
|
|
total_new = len(new_questions)
|