Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct chat history date filtering logic #351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sanaderer
Copy link

Description

Fix incorrect date filtering logic in chat history. The previous implementation had a logical error where date comparisons were made against the chat's own date instead of the current date, causing incorrect grouping of chats in time periods.

Changes made

  • Added reference dates (now, oneWeekAgo, oneMonthAgo) outside the loop for better performance
  • Fixed date comparison logic to correctly filter chats into their respective periods:
    • 1d: Today's chats only
    • 7d: Chats from last 7 days (excluding today)
    • 30d: Chats from 8-30 days ago
  • Added else if statements to ensure chats appear in only one category

Problem solved

Previously, the date comparison logic was comparing chat dates against themselves plus an offset, which would always return true. This fix ensures chats are properly categorized based on their actual age relative to the current date.

How to test

  1. Create chats with different dates
  2. Verify that:
    • Today's chats appear only in "1d"
    • Last week's chats (excluding today) appear in "7d"
    • Older chats (8-30 days) appear in "30d"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant