Explorar o código

Minor optimizations in updater

Jordi Boggiano %!s(int64=8) %!d(string=hai) anos
pai
achega
fe5bd85e7e
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      src/Packagist/WebBundle/Package/Updater.php

+ 5 - 2
src/Packagist/WebBundle/Package/Updater.php

@@ -211,7 +211,7 @@ class Updater
 
 
         $package->setUpdatedAt(new \DateTime);
         $package->setUpdatedAt(new \DateTime);
         $package->setCrawledAt(new \DateTime);
         $package->setCrawledAt(new \DateTime);
-        $em->flush();
+        $em->flush($package);
         if ($repository->hadInvalidBranches()) {
         if ($repository->hadInvalidBranches()) {
             throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
             throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
         }
         }
@@ -344,7 +344,10 @@ class Updater
                     }
                     }
                 }
                 }
 
 
-                $author->setUpdatedAt(new \DateTime);
+                // only update the author timestamp once a month at most as the value is kinda unused
+                if ($author->getUpdatedAt() === null || $author->getUpdatedAt()->getTimestamp() < time() - 86400 * 30) {
+                    $author->setUpdatedAt(new \DateTime);
+                }
                 if (!$version->getAuthors()->contains($author)) {
                 if (!$version->getAuthors()->contains($author)) {
                     $version->addAuthor($author);
                     $version->addAuthor($author);
                 }
                 }