code: public List<StatusTrail> getIncompleteTasks(DataSource ds) {
          EntityManager em = getEntityManager();
          try {        
              return em.createQuery("SELECT st FROM StatusTrail st WHERE st.dataSourceId = :dataSourceId "
                      + "AND st.status = 'not_done' AND st.givenUp = 0 ORDER BY st.id DESC", 
                      StatusTrail.class).
                      setParameter("dataSourceId", ds.getId()).getResultList();        
          } finally {
              em.close();
          }
      }
docs: Tasks whose status:not_done and givenUp:zero
  @param ds
  @return