public function execute()
    {
        $addresses = $this->addressRepository->createQueryBuilder('a')
            ->where('a.latitude IS NULL')
            ->orWhere('a.longitude IS NULL')
            ->setMaxResults(500)
            ->getQuery()
            ->getResult();

        foreach ($addresses as $address) {
            try {
                $this->updateLatLong($address);
            } catch (\RuntimeException $e) {
                echo "Stopping work -- over the API query limit.\n";

                break;
            }

            $this->entityManager->persist($address);

            usleep(self::MILLISECONDS_PAUSE_BETWEEN_QUERIES);
        }

        $this->entityManager->flush();
    }
public function execute()
    {
        $addresses = $this->addressRepository->createQueryBuilder('a')
            ->where('a.latitude IS NULL')
            ->orWhere('a.longitude IS NULL')
            ->setMaxResults(500)
            ->getQuery()
            ->getResult();

        foreach ($addresses as $address) {
            try {
                $this->updateLatLong($address);
            } catch (\RuntimeException $e) {
                echo "Stopping work -- over the API query limit.\n";

                break;
            }

            $this->entityManager->persist($address);

            usleep(self::MILLISECONDS_PAUSE_BETWEEN_QUERIES);
        }

        $this->entityManager->flush();
    }
public function execute ( ) { $ addresses = $ this -> addressRepository -> createQueryBuilder ( 'a' ) -> where ( 'a.latitude IS NULL' ) -> orWhere ( 'a.longitude IS NULL' ) -> setMaxResults ( 500 ) -> getQuery ( ) -> getResult ( ) ; foreach ( $ addresses as $ address ) { try { $ this -> updateLatLong ( $ address ) ; } catch ( \ RuntimeException $ e ) { echo "Stopping work -- over the API query limit.\n" ; break ; } $ this -> entityManager -> persist ( $ address ) ; usleep ( self :: MILLISECONDS_PAUSE_BETWEEN_QUERIES ) ; } $ this -> entityManager -> flush ( ) ; }
Execute the work

@return void
Execute the work