File tree Expand file tree Collapse file tree
apps/backend-convex/convex Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ crons.daily(
2323
2424crons . interval (
2525 'resolve stuck stream messages' ,
26- { hours : 1 } ,
26+ { minutes : 10 } ,
2727 internal . messages . resolveStuckStreamMessages ,
2828)
2929
Original file line number Diff line number Diff line change @@ -138,9 +138,10 @@ export const resolveStuckStreamMessages = internalMutation({
138138 handler : async ( ctx ) => {
139139 const messages = await ctx . db
140140 . query ( 'messages' )
141- . filter ( q => q . eq ( q . field ( 'isStreaming' ) , true ) )
142141 // Get streams that are older than 15 minutes
143- . filter ( q => q . lt ( q . field ( 'timestamp' ) , Date . now ( ) - 15 * 60 * 1000 ) )
142+ . withIndex ( 'by_timestamp' , q =>
143+ q . lte ( 'timestamp' , Date . now ( ) - 15 * 60 * 1000 ) )
144+ . filter ( q => q . eq ( q . field ( 'isStreaming' ) , true ) )
144145 . collect ( )
145146
146147 if ( ! messages . length )
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const aiChatTables = {
2929 } )
3030 . index ( 'by_thread' , [ 'threadId' ] )
3131 . index ( 'by_thread_and_timestamp' , [ 'threadId' , 'timestamp' ] )
32+ . index ( 'by_timestamp' , [ 'timestamp' ] )
3233 . index ( 'by_stream_id' , [ 'streamId' ] ) ,
3334}
3435
You can’t perform that action at this time.
0 commit comments