Skip to content

Commit

Permalink
fix: an issue of keyword search feature in application log list (lang…
Browse files Browse the repository at this point in the history
  • Loading branch information
realethanhsu authored and cuiks committed Sep 2, 2024
1 parent 70f3fe7 commit 1ed1dca
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions api/controllers/console/app/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,18 @@ def get(self, app_model):

if args["keyword"]:
keyword_filter = "%{}%".format(args["keyword"])
query = (
query.join(
Message,
Message.conversation_id == Conversation.id,
)
.join(subquery, subquery.c.conversation_id == Conversation.id)
.filter(
or_(
Message.query.ilike(keyword_filter),
Message.answer.ilike(keyword_filter),
Conversation.name.ilike(keyword_filter),
Conversation.introduction.ilike(keyword_filter),
subquery.c.from_end_user_session_id.ilike(keyword_filter),
),
)
message_subquery = (
db.session.query(Message.conversation_id)
.filter(or_(Message.query.ilike(keyword_filter), Message.answer.ilike(keyword_filter)))
.subquery()
)
query = query.join(subquery, subquery.c.conversation_id == Conversation.id).filter(
or_(
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
Expand Down

0 comments on commit 1ed1dca

Please sign in to comment.