queryset.annotate(
last_job_status=Window(
expression=LastValue("workitem__job__status"),
partition_by=F('workitem__id'),
order_by=F('workitem__job__id')
)
).filter(last_job_status=Job.STATE_COMPLETED)