Skip to content

Commit

Permalink
chore: langgenius#7348, support query conversations by updated_at (la…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuzooVn authored and lau-td committed Oct 23, 2024
1 parent 00e97df commit c556a59
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/controllers/console/app/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ def get(self, app_model):
start_datetime_timezone = timezone.localize(start_datetime)
start_datetime_utc = start_datetime_timezone.astimezone(utc_timezone)

query = query.where(Conversation.created_at >= start_datetime_utc)
match args["sort_by"]:
case "updated_at" | "-updated_at":
query = query.where(Conversation.updated_at >= start_datetime_utc)
case "created_at" | "-created_at" | _:
query = query.where(Conversation.created_at >= start_datetime_utc)

if args["end"]:
end_datetime = datetime.strptime(args["end"], "%Y-%m-%d %H:%M")
Expand All @@ -210,7 +214,11 @@ def get(self, app_model):
end_datetime_timezone = timezone.localize(end_datetime)
end_datetime_utc = end_datetime_timezone.astimezone(utc_timezone)

query = query.where(Conversation.created_at < end_datetime_utc)
match args["sort_by"]:
case "updated_at" | "-updated_at":
query = query.where(Conversation.updated_at <= end_datetime_utc)
case "created_at" | "-created_at" | _:
query = query.where(Conversation.created_at <= end_datetime_utc)

if args["annotation_status"] == "annotated":
query = query.options(joinedload(Conversation.message_annotations)).join(
Expand Down

0 comments on commit c556a59

Please sign in to comment.