@classmethod
    def handle_result(cls, job, queue):
        """Get the next job in the flow sequence"""
        if job.if_result:
            next_job = Job.objects.get(uuid=job.if_result)
            next_job.queue_id = queue.name
            next_job.enqueued_at = now()
            next_job.status = Job.QUEUED
            next_job.save()
            queue.notify(next_job.id)
        else:  # maybe last job
            fs = FlowStore.objects.get(pk=job.flow_id)
            if fs.jobs[-1] == job.id and job.expired_at < now():
                fs.delete()
            elif fs.jobs[-1] == job.id:
                fs.ended_at = job.ended_at
                fs.expired_at = job.expired_at
                fs.status = FlowStore.FINISHED
                fs.save()
dataset/ETHPy150Open bretth/django-pq/pq/flow.py/Flow.handle_result/original