17 lines
742 B
TypeScript
17 lines
742 B
TypeScript
import { listPendingJobs } from '~/server/utils/pending'
|
|
import { listOwnersWithQueues, listShotQueues, pendingSegmentCount } from '~/server/utils/shotQueue'
|
|
import { startQueueBurst } from '~/server/utils/videoChain'
|
|
|
|
export default defineNitroPlugin(() => {
|
|
const pendingQueueIds = new Set(listPendingJobs().map(job => job.queueId).filter(Boolean))
|
|
for (const owner of listOwnersWithQueues()) {
|
|
for (const queue of listShotQueues(owner)) {
|
|
if (!queue.autoRun) continue
|
|
if (queue.status === 'complete') continue
|
|
if (pendingQueueIds.has(queue.id)) continue
|
|
if (!queue.currentClipId || pendingSegmentCount(queue) === 0) continue
|
|
void startQueueBurst(owner, queue.id, 'all').catch(() => null)
|
|
}
|
|
}
|
|
})
|