def extra_job_filters(not_yet_run=False, running=False, finished=False):
 assert (not ((not_yet_run and running) or (not_yet_run and finished) or (running and finished))), 'Cannot specify more than one filter to this function'
 not_queued = ('(SELECT job_id FROM afe_host_queue_entries WHERE status != "%s")' % models.HostQueueEntry.Status.QUEUED)
 not_finished = '(SELECT job_id FROM afe_host_queue_entries WHERE not complete)'
 if not_yet_run:
  where = [('id NOT IN ' + not_queued)]
 elif running:
  where = [('(id IN %s) AND (id IN %s)' % (not_queued, not_finished))]
 elif finished:
  where = [('id NOT IN ' + not_finished)]
 else:
  return {}
 return {'where': where}

def extra_job_filters ( not_yet_run = False , running = False , finished = False ) : assert ( not ( ( not_yet_run and running ) or ( not_yet_run and finished ) or ( running and finished ) ) ) , 'Cannot specify more than one filter to this function' not_queued = ( '(SELECT job_id FROM afe_host_queue_entries WHERE status != "%s")' % models . HostQueueEntry . Status . QUEUED ) not_finished = '(SELECT job_id FROM afe_host_queue_entries WHERE not complete)' if not_yet_run : where = [ ( 'id NOT IN ' + not_queued ) ] elif running : where = [ ( '(id IN %s) AND (id IN %s)' % ( not_queued , not_finished ) ) ] elif finished : where = [ ( 'id NOT IN ' + not_finished ) ] else : return { } return { 'where' : where }
generate a sql where clause for job status filtering .