code: def expire_filter(lte_time, conn=None):
      
      if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn):
          return (r.row[EXPIRE_FIELD] <= lte_time)
      else:
          return (
              (
                  (r.row[STATUS_FIELD] == WAITING) |
                  (r.row[STATUS_FIELD] == READY)
              ) &
              (r.row[EXPIRE_FIELD] <= lte_time)
          )
docs: generates a filter for status==waiting and
      time older than lte_time