File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -65,18 +65,18 @@ export default {
6565 )
6666 )
6767 . orderBy ( asc ( sql `date(timestamp)` ) )
68+ . limit ( 99 ) // Limit to 99 days which is the limit of the workflow instances
6869 . catch ( ( error ) => {
6970 throw new Error ( "Failed to get dates" , { cause : error } ) ;
7071 } ) ;
7172 const days = allDates . map ( ( date ) => new Date ( date . day as string ) ) ;
72- for ( const day of days ) {
73- const workflowInstance = await env . WORKFLOW_OVERNIGHT_SAVE_TO_R2 . create ( {
74- params : {
75- dayToProcess : day ,
76- } ,
77- } ) ;
78- await workflowInstance . status ( ) ;
79- }
73+ // Create a new batch of 3 Workflow instances, each with its own ID and pass params to the Workflow instances
74+ await env . WORKFLOW_OVERNIGHT_SAVE_TO_R2 . createBatch (
75+ days . map ( ( day ) => ( {
76+ params : { dayToProcess : day } ,
77+ } ) )
78+ ) ;
79+ console . log ( `Created ${ days . length } workflow instances` ) ;
8080 } ,
8181} satisfies ExportedHandler < Env > ;
8282
Original file line number Diff line number Diff line change 7272 },
7373 "preview_urls" : false ,
7474 "triggers" : {
75- "crons" : [" 30 2 * * *" ] // every day at 2:30 AM UTC
75+ "crons" : [" 15 10 * * *" ] // every day at 10:15 AM UTC
7676 },
7777 "version_metadata" : {
7878 "binding" : " CF_VERSION_METADATA"
You can’t perform that action at this time.
0 commit comments