Skip to content
Merged
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
24 changes: 16 additions & 8 deletions web/src/app/chat/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ import { INTERNET_SEARCH_TOOL_ID } from "./tools/constants";
import { SEARCH_TOOL_ID } from "./tools/constants";
import { IIMAGE_GENERATION_TOOL_ID } from "./tools/constants";

// Date range group constants
export const DATE_RANGE_GROUPS = {
TODAY: "Today",
PREVIOUS_7_DAYS: "Previous 7 Days",
PREVIOUS_30_DAYS: "Previous 30 Days",
OVER_30_DAYS: "Over 30 Days",
} as const;

interface ChatRetentionInfo {
chatRetentionDays: number;
daysFromCreation: number;
Expand Down Expand Up @@ -421,10 +429,10 @@ export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison

const groups: Record<string, ChatSession[]> = {
Today: [],
"Previous 7 Days": [],
"Previous 30 days": [],
"Over 30 days": [],
[DATE_RANGE_GROUPS.TODAY]: [],
[DATE_RANGE_GROUPS.PREVIOUS_7_DAYS]: [],
[DATE_RANGE_GROUPS.PREVIOUS_30_DAYS]: [],
[DATE_RANGE_GROUPS.OVER_30_DAYS]: [],
};

chatSessions.forEach((chatSession) => {
Expand All @@ -434,22 +442,22 @@ export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
const diffDays = diffTime / (1000 * 3600 * 24); // Convert time difference to days

if (diffDays < 1) {
const groups_today = groups["Today"];
const groups_today = groups[DATE_RANGE_GROUPS.TODAY];
if (groups_today) {
groups_today.push(chatSession);
}
} else if (diffDays <= 7) {
const groups_7 = groups["Previous 7 Days"];
const groups_7 = groups[DATE_RANGE_GROUPS.PREVIOUS_7_DAYS];
if (groups_7) {
groups_7.push(chatSession);
}
} else if (diffDays <= 30) {
const groups_30 = groups["Previous 30 Days"];
const groups_30 = groups[DATE_RANGE_GROUPS.PREVIOUS_30_DAYS];
if (groups_30) {
groups_30.push(chatSession);
}
} else {
const groups_over_30 = groups["Over 30 days"];
const groups_over_30 = groups[DATE_RANGE_GROUPS.OVER_30_DAYS];
if (groups_over_30) {
groups_over_30.push(chatSession);
}
Expand Down
Loading