Fix date filters not working

This commit is contained in:
Ilango
2024-02-27 15:35:49 +05:30
parent 26c52398a0
commit 5698a62618
+5 -8
View File
@@ -1542,14 +1542,11 @@ export class App {
.where('chat_message.chatflowid = :chatflowid', { chatflowid }) .where('chat_message.chatflowid = :chatflowid', { chatflowid })
.andWhere(chatType ? 'chat_message.chatType = :chatType' : 'TRUE', { chatType }) .andWhere(chatType ? 'chat_message.chatType = :chatType' : 'TRUE', { chatType })
.andWhere(chatId ? 'chat_message.chatId = :chatId' : 'TRUE', { chatId }) .andWhere(chatId ? 'chat_message.chatId = :chatId' : 'TRUE', { chatId })
.andWhere(memoryType ? 'chat_message.memoryType = :memoryType' : 'TRUE', { .andWhere(memoryType ? 'chat_message.memoryType = :memoryType' : 'TRUE', { memoryType })
memoryType: memoryType ?? (chatId ? IsNull() : undefined) .andWhere(sessionId ? 'chat_message.sessionId = :sessionId' : 'TRUE', { sessionId })
}) .andWhere('chat_message.createdDate BETWEEN :fromDate AND :toDate', {
.andWhere(sessionId ? 'chat_message.sessionId = :sessionId' : 'TRUE', { fromDate: fromDate ?? new Date().setMonth(new Date().getMonth() - 1),
sessionId: sessionId ?? (chatId ? IsNull() : undefined) toDate: toDate ?? new Date()
})
.andWhere(fromDate && toDate ? 'chat_message.createdDate = :createdDate' : 'TRUE', {
createdDate: toDate && fromDate ? Between(fromDate, toDate) : undefined
}) })
.orderBy('chat_message.createdDate', sortOrder === 'DESC' ? 'DESC' : 'ASC') .orderBy('chat_message.createdDate', sortOrder === 'DESC' ? 'DESC' : 'ASC')
.getMany() .getMany()