fix: an issue of keyword search feature in application log list (#7816)

This commit is contained in:
Ethan 2024-08-30 18:48:05 +08:00 committed by GitHub
parent 62bfc4dba6
commit ea748b50f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -173,22 +173,19 @@ class ChatConversationApi(Resource):
if args["keyword"]:
keyword_filter = "%{}%".format(args["keyword"])
query = (
query.join(
Message,
Message.conversation_id == Conversation.id,
message_subquery = (
db.session.query(Message.conversation_id)
.filter(or_(Message.query.ilike(keyword_filter), Message.answer.ilike(keyword_filter)))
.subquery()
)
.join(subquery, subquery.c.conversation_id == Conversation.id)
.filter(
query = query.join(subquery, subquery.c.conversation_id == Conversation.id).filter(
or_(
Message.query.ilike(keyword_filter),
Message.answer.ilike(keyword_filter),
Conversation.id.in_(message_subquery),
Conversation.name.ilike(keyword_filter),
Conversation.introduction.ilike(keyword_filter),
subquery.c.from_end_user_session_id.ilike(keyword_filter),
),
)
)
account = current_user
timezone = pytz.timezone(account.timezone)