Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/server/src/utils/getChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const utilGetChatMessage = async ({
}
}

const messages = await appServer.AppDataSource.getRepository(ChatMessage).find({
const queryOptions: any = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using any for queryOptions. Using FindManyOptions<ChatMessage> provides better type safety and ensures that the options are valid for the ChatMessage entity. Since FindManyOptions is not currently imported in this file, you can use an inline import or add it to the typeorm imports at the top of the file.

Suggested change
const queryOptions: any = {
const queryOptions: import('typeorm').FindManyOptions<ChatMessage> = {

where: {
chatflowid,
chatType: chatTypes?.length ? In(chatTypes) : undefined,
Expand All @@ -116,7 +116,15 @@ export const utilGetChatMessage = async ({
order: {
createdDate: sortOrder === 'DESC' ? 'DESC' : 'ASC'
}
})
}

// Apply pagination if page and pageSize are provided
if (page > 0 && pageSize > 0) {
queryOptions.skip = (page - 1) * pageSize
queryOptions.take = pageSize
}
Comment on lines +122 to +125
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pagination logic implemented here is message-based (returning a fixed number of messages), while the handleFeedbackQuery function (lines 168-226) implements session-based pagination (returning all messages for a fixed number of sessions). This results in inconsistent behavior for the limit and page parameters depending on whether feedback=true is passed. While this difference might be intentional for feedback context, it contradicts the PR description's claim of consistent pagination behavior.


const messages = await appServer.AppDataSource.getRepository(ChatMessage).find(queryOptions)

return messages
}
Expand Down