mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
修复匹配时候忽视了word_type的约束
This commit is contained in:
parent
3bb9aaf637
commit
f570bffcf7
@ -234,19 +234,21 @@ class WordBank(db.Model):
|
|||||||
query = query.where(cls.word_scope == word_type)
|
query = query.where(cls.word_scope == word_type)
|
||||||
sql_text += f" and word_scope = {word_scope}"
|
sql_text += f" and word_scope = {word_scope}"
|
||||||
# 完全匹配
|
# 完全匹配
|
||||||
if await query.where(cls.problem == problem).gino.first():
|
if await query.where(((cls.word_type == 0) | (cls.word_type == 3)) & (cls.problem == problem)).gino.first():
|
||||||
return query.where(cls.problem == problem)
|
return query.where(cls.problem == problem)
|
||||||
|
# 模糊匹配
|
||||||
|
if await query.where((cls.word_type == 1) & (cls.problem.contains(problem))).gino.first():
|
||||||
|
return query.where(cls.problem.contains(problem))
|
||||||
# 正则匹配
|
# 正则匹配
|
||||||
if await db.first(
|
if await db.first(
|
||||||
db.text(sql_text + f" and word_type = 2 and '{problem}' ~ problem;")
|
db.text(sql_text + f" and word_type = 2 and word_scope != 999 and '{problem}' ~ problem;")
|
||||||
):
|
):
|
||||||
return sql_text + f" and word_type = 2 and '{problem}' ~ problem;"
|
return sql_text + f" and word_type = 2 and word_scope != 999 and '{problem}' ~ problem;"
|
||||||
# 模糊匹配
|
# if await db.first(
|
||||||
if await db.first(
|
# db.text(sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;")
|
||||||
db.text(sql_text + f" and word_type = 1 and '{problem}' ~ problem;")
|
# ):
|
||||||
):
|
# return sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;"
|
||||||
return sql_text + f" and word_type = 1 and '{problem}' ~ problem;"
|
# return None
|
||||||
return None
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_answer(
|
async def get_answer(
|
||||||
@ -456,4 +458,4 @@ class WordBank(db.Model):
|
|||||||
)
|
)
|
||||||
problem_list.append(problem)
|
problem_list.append(problem)
|
||||||
_tmp.append(q.problem)
|
_tmp.append(q.problem)
|
||||||
return problem_list
|
return problem_list
|
||||||
Loading…
Reference in New Issue
Block a user