code: public function findElementToAutoPublish($siteId, array $fromStatus)
      {
          $date = new \Mongodate(strtotime(date('d F Y')));
  
          $statusIds = array();
          foreach($fromStatus as $status) {
              $statusIds[] = new \MongoId($status->getId());
          }
  
          $qa = $this->createAggregationQuery();
  
          $filter = array(
              'siteId' => $siteId,
              'deleted' => false,
              'status._id' => array('$in' => $statusIds),
              'status.outOfWorkflow' => false,
              'publishDate' => array('$lte' => $date),
              '$or' => array(
                  array('unpublishDate' => array('$exists' => false)),
                  array('unpublishDate' => array('$gte' => $date))
              )
          );
  
          $qa->match($filter);
          $qa->sort(array('createdAt' => 1));
  
          return $this->hydrateAggregateQuery($qa);
      }
docs: Find all element (in all versions and all languages) ready to be auto-published
  
  @param string $siteId
  @param array  $fromStatus
  
  @return array