Skip to content

Commit

Permalink
fix: timezone not imported in conversation service. (#11076)
Browse files Browse the repository at this point in the history
  • Loading branch information
laipz8200 authored Nov 25, 2024
1 parent 1065917 commit c032574
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/services/conversation_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Callable
from datetime import UTC, datetime
from typing import Optional, Union

Expand Down Expand Up @@ -74,14 +75,14 @@ def pagination_by_last_id(
return InfiniteScrollPagination(data=conversations, limit=limit, has_more=has_more)

@classmethod
def _get_sort_params(cls, sort_by: str) -> tuple[str, callable]:
def _get_sort_params(cls, sort_by: str):
if sort_by.startswith("-"):
return sort_by[1:], desc
return sort_by, asc

@classmethod
def _build_filter_condition(
cls, sort_field: str, sort_direction: callable, reference_conversation: Conversation, is_next_page: bool = False
cls, sort_field: str, sort_direction: Callable, reference_conversation: Conversation, is_next_page: bool = False
):
field_value = getattr(reference_conversation, sort_field)
if (sort_direction == desc and not is_next_page) or (sort_direction == asc and is_next_page):
Expand Down Expand Up @@ -160,5 +161,5 @@ def delete(cls, app_model: App, conversation_id: str, user: Optional[Union[Accou
conversation = cls.get_conversation(app_model, conversation_id, user)

conversation.is_deleted = True
conversation.updated_at = datetime.now(timezone.utc).replace(tzinfo=None)
conversation.updated_at = datetime.now(UTC).replace(tzinfo=None)
db.session.commit()

0 comments on commit c032574

Please sign in to comment.