@@ -36,6 +36,14 @@ import { INTERNET_SEARCH_TOOL_ID } from "./tools/constants";
3636import { SEARCH_TOOL_ID } from "./tools/constants" ;
3737import { IMAGE_GENERATION_TOOL_ID } from "./tools/constants" ;
3838
39+ // Date range group constants
40+ export const DATE_RANGE_GROUPS = {
41+ TODAY : "Today" ,
42+ PREVIOUS_7_DAYS : "Previous 7 Days" ,
43+ PREVIOUS_30_DAYS : "Previous 30 Days" ,
44+ OVER_30_DAYS : "Over 30 Days" ,
45+ } as const ;
46+
3947interface ChatRetentionInfo {
4048 chatRetentionDays : number ;
4149 daysFromCreation : number ;
@@ -421,10 +429,10 @@ export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
421429 today . setHours ( 0 , 0 , 0 , 0 ) ; // Set to start of today for accurate comparison
422430
423431 const groups : Record < string , ChatSession [ ] > = {
424- Today : [ ] ,
425- "Previous 7 Days" : [ ] ,
426- "Previous 30 days" : [ ] ,
427- "Over 30 days" : [ ] ,
432+ [ DATE_RANGE_GROUPS . TODAY ] : [ ] ,
433+ [ DATE_RANGE_GROUPS . PREVIOUS_7_DAYS ] : [ ] ,
434+ [ DATE_RANGE_GROUPS . PREVIOUS_30_DAYS ] : [ ] ,
435+ [ DATE_RANGE_GROUPS . OVER_30_DAYS ] : [ ] ,
428436 } ;
429437
430438 chatSessions . forEach ( ( chatSession ) => {
@@ -434,22 +442,22 @@ export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
434442 const diffDays = diffTime / ( 1000 * 3600 * 24 ) ; // Convert time difference to days
435443
436444 if ( diffDays < 1 ) {
437- const groups_today = groups [ "Today" ] ;
445+ const groups_today = groups [ DATE_RANGE_GROUPS . TODAY ] ;
438446 if ( groups_today ) {
439447 groups_today . push ( chatSession ) ;
440448 }
441449 } else if ( diffDays <= 7 ) {
442- const groups_7 = groups [ "Previous 7 Days" ] ;
450+ const groups_7 = groups [ DATE_RANGE_GROUPS . PREVIOUS_7_DAYS ] ;
443451 if ( groups_7 ) {
444452 groups_7 . push ( chatSession ) ;
445453 }
446454 } else if ( diffDays <= 30 ) {
447- const groups_30 = groups [ "Previous 30 Days" ] ;
455+ const groups_30 = groups [ DATE_RANGE_GROUPS . PREVIOUS_30_DAYS ] ;
448456 if ( groups_30 ) {
449457 groups_30 . push ( chatSession ) ;
450458 }
451459 } else {
452- const groups_over_30 = groups [ "Over 30 days" ] ;
460+ const groups_over_30 = groups [ DATE_RANGE_GROUPS . OVER_30_DAYS ] ;
453461 if ( groups_over_30 ) {
454462 groups_over_30 . push ( chatSession ) ;
455463 }
0 commit comments