Skip to content

Commit

Permalink
fixed query history
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Nov 7, 2024
1 parent d1a6ce9 commit f560a1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/ee/danswer/db/query_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def fetch_chat_sessions_eagerly_by_time(
]

if initial_time:
filters.append(ChatSession.time_created < initial_time)
filters.append(ChatSession.time_created > initial_time)

subquery = (
db_session.query(ChatSession.id, ChatSession.time_created)
Expand Down
17 changes: 8 additions & 9 deletions backend/ee/danswer/db/usage_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_empty_chat_messages_entries__paginated(
period: tuple[datetime, datetime],
limit: int | None = 500,
initial_time: datetime | None = None,
) -> list[ChatMessageSkeleton]:
) -> tuple[int, list[ChatMessageSkeleton]]:
chat_sessions = fetch_chat_sessions_eagerly_by_time(
start=period[0],
end=period[1],
Expand Down Expand Up @@ -53,8 +53,9 @@ def get_empty_chat_messages_entries__paginated(
time_sent=message.time_sent,
)
)

return message_skeletons
if len(chat_sessions) == 0:
return None, []
return chat_sessions[0].time_created, message_skeletons


def get_all_empty_chat_message_entries(
Expand All @@ -65,22 +66,20 @@ def get_all_empty_chat_message_entries(
ind = 0
while True:
ind += 1
print(ind)
print(initial_time)
message_skeletons = get_empty_chat_messages_entries__paginated(

time_created, message_skeletons = get_empty_chat_messages_entries__paginated(
db_session,
period,
initial_time=initial_time,
)
print("length", len(message_skeletons))

if not message_skeletons:
return

yield message_skeletons

# Update initial_time for the next iteration
last_message = message_skeletons[-1]
initial_time = last_message.time_sent
initial_time = time_created


def get_all_usage_reports(db_session: Session) -> list[UsageReportMetadata]:
Expand Down

0 comments on commit f560a1f

Please sign in to comment.