瀏覽代碼

Fix per-version download stats

Jordi Boggiano 6 年之前
父節點
當前提交
c421c736be
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/Packagist/WebBundle/Model/DownloadManager.php

+ 5 - 2
src/Packagist/WebBundle/Model/DownloadManager.php

@@ -58,12 +58,12 @@ class DownloadManager
 
         if ($version !== null) {
             $id = $version;
-            $type = Download::TYPE_PACKAGE;
+            $type = Download::TYPE_VERSION;
             $keyBase .= '-'.$version;
         }
 
         $record = $this->doctrine->getRepository(Download::class)->findOneBy(['id' => $id, 'type' => $type]);
-        $dlData = $record ? $record->data : [];
+        $dlData = $record ? $record->getData() : [];
 
         $keyBase .= ':';
         $date = new \DateTime();
@@ -84,6 +84,9 @@ class DownloadManager
         }
 
         $total = (int) $redisData[2];
+        if ($version) {
+            $total = $record ? $record->getTotal() : 0;
+        }
 
         // how much of yesterday to add to today to make it a whole day (sort of..)
         $dayRatio = (2400 - (int) date('Hi')) / 2400;