-- 'ES.setJobStage' and potentially queue iff the new stage is different from
-- the current.
setAndPerhapsQueue :: (TS m)
                   => Job.Status -- ^ Original status
                   -> Job.Stage  -- ^ New status
                   -> m ()
setAndPerhapsQueue s st' = when (s ^. Job.stage /= st') $ do
    ES.setJobStage (s ^. Job.name) st'
    when (st' == Queued LocalQueue) . ES.schedule =<< mkQueueJob (s ^. Job.spec) (s ^. Job.uuid)
setAndPerhapsQueue :: (TS m)
                   => Job.Status -- ^ Original status
                   -> Job.Stage  -- ^ New status
                   -> m ()
setAndPerhapsQueue s st' = when (s ^. Job.stage /= st') $ do
    ES.setJobStage (s ^. Job.name) st'
    when (st' == Queued LocalQueue) . ES.schedule =<< mkQueueJob (s ^. Job.spec) (s ^. Job.uuid)
setAndPerhapsQueue s st' = when (s ^. Job.stage /= st') $ do
    ES.setJobStage (s ^. Job.name) st'
    when (st' == Queued LocalQueue) . ES.schedule =<< mkQueueJob (s ^. Job.spec) (s ^. Job.uuid)