yii2-queue icon indicating copy to clipboard operation
yii2-queue copied to clipboard

Check status by class name

Open nicdnepr opened this issue 4 years ago • 5 comments

From docs - to see status need pass job id

if (!Yii::$app->queue->isDone($id))
echo 'working...'

What about check status by class name? For example Yii::$app->queue->isAnyWorking(testJob::class) which mean- is any not done job for class TestJob?

nicdnepr avatar Jun 21 '20 19:06 nicdnepr

What is the use case for it?

samdark avatar Jun 22 '20 22:06 samdark

For example-I need add many users to system I create 10 queue jobs, then from frontend I check if (Yii::$app->queue->isAnyWorking(testJob::class)) then echo 'add in progress' Now I need save all ids and then in loop check

foreach ($idList as $id) {
    if (Yii::$app->queue->isWaiting($id) || Yii::$app->queue->isReserved($id)) {
        echo 'working...'
         break;
    }
}

nicdnepr avatar Jun 23 '20 03:06 nicdnepr

OK. That may be useful.

samdark avatar Jun 23 '20 14:06 samdark

Any idea how do you want to implement it? Most of backends does not allow to filter by anything except job ID, so the only way to do this would be to log IDs of jobs and query each of them separately. Exactly in the same way as you're doing it now.

rob006 avatar Jun 23 '20 17:06 rob006

Yes. With the current info stored it is exactly how @rob006 suggests it.

samdark avatar Jun 23 '20 17:06 samdark