You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I keep running into the need of needing to know when a job completes.
e.g. I am queueing X jobs to do Y, and then I need to tell user when all of those jobs have completed.
I am using JavaScript SDK.
I am currently achieving this by logging completion in the database and having a while {} loop that checks for all job completion, e.g.
constsourceArticleIds: number[]=[];for(constarticleUrlofreferenceArticleUrls){// ...awaitinngest.send({data: {sourceArticleId: newSourceArticleId,},name: 'aimd/download-article.start',});sourceArticleIds.push(newSourceArticleId);}awaitwait({check: async()=>{constpendingSourceArticleIds=awaitpool.anyFirst(sql` SELECT id FROM source_article WHERE id = ANY(${sql.array(sourceArticleIds,'int4')}) AND ended_at IS NULL `);returnpendingSourceArticleIds.length===0;},name: 'download-article.complete',timeout: 60_000,});
...but it feels like there should be a better way to do it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I keep running into the need of needing to know when a job completes.
e.g. I am queueing X jobs to do Y, and then I need to tell user when all of those jobs have completed.
I am using JavaScript SDK.
I am currently achieving this by logging completion in the database and having a
while {}
loop that checks for all job completion, e.g....but it feels like there should be a better way to do it.
Beta Was this translation helpful? Give feedback.
All reactions