File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
apps/webapp/app/presenters/v3 Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,19 @@ export class PromptPresenter extends BasePresenter {
124124 return { } ;
125125 }
126126
127- // Build a map of slug -> 24 hourly buckets
127+ // Build a map of slug -> 24 hourly buckets (use UTC to match ClickHouse)
128128 const now = new Date ( ) ;
129- const startHour = new Date ( now ) ;
130- startHour . setMinutes ( 0 , 0 , 0 ) ;
131- startHour . setHours ( startHour . getHours ( ) - 23 ) ;
129+ const startHour = new Date ( Date . UTC (
130+ now . getUTCFullYear ( ) ,
131+ now . getUTCMonth ( ) ,
132+ now . getUTCDate ( ) ,
133+ now . getUTCHours ( ) - 23 ,
134+ 0 , 0 , 0
135+ ) ) ;
132136
133137 const bucketKeys : string [ ] = [ ] ;
134138 for ( let i = 0 ; i < 24 ; i ++ ) {
135- const h = new Date ( startHour ) ;
136- h . setHours ( h . getHours ( ) + i ) ;
139+ const h = new Date ( startHour . getTime ( ) + i * 3600_000 ) ;
137140 // Format to match ClickHouse's toStartOfHour output: "YYYY-MM-DD HH:MM:SS"
138141 bucketKeys . push (
139142 h . toISOString ( ) . slice ( 0 , 13 ) . replace ( "T" , " " ) + ":00:00"
You can’t perform that action at this time.
0 commit comments