PackageRepository.php 868 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /*
  3. * This file is part of Packagist.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. * Nils Adermann <naderman@naderman.de>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Packagist\WebBundle\Entity;
  12. use Doctrine\ORM\EntityRepository;
  13. /**
  14. * @author Jordi Boggiano <j.boggiano@seld.be>
  15. */
  16. class PackageRepository extends EntityRepository
  17. {
  18. public function getStalePackages()
  19. {
  20. $qb = $this->getEntityManager()->createQueryBuilder();
  21. $qb->select('p, v')
  22. ->from('Packagist\WebBundle\Entity\Package', 'p')
  23. ->leftJoin('p.versions', 'v')
  24. ->where('p.crawledAt IS NULL OR p.crawledAt < ?0')
  25. ->setParameters(array(new \DateTime('-1hour')));
  26. return $qb->getQuery()->getResult();
  27. }
  28. }