Browse Source

Delete outdated code

Jordi Boggiano 6 years ago
parent
commit
7e4bd39321
1 changed files with 0 additions and 77 deletions
  1. 0 77
      src/Packagist/WebBundle/Command/CompileStatsCommand.php

+ 0 - 77
src/Packagist/WebBundle/Command/CompileStatsCommand.php

@@ -49,56 +49,6 @@ class CompileStatsCommand extends ContainerAwareCommand
         $conn = $doctrine->getManager()->getConnection();
         $this->redis = $redis = $this->getContainer()->get('snc_redis.default');
 
-        // TODO delete this whole block mid-august 2018
-        $minMax = $conn->fetchAssoc('SELECT MAX(id) maxId, MIN(id) minId FROM package');
-        if (!isset($minMax['minId'])) {
-            return 0;
-        }
-
-        $ids = range($minMax['minId'], $minMax['maxId']);
-        $res = $conn->fetchAssoc('SELECT MIN(createdAt) minDate FROM package');
-        $date = new \DateTime($res['minDate']);
-        $date->modify('00:00:00');
-        $yesterday = new \DateTime('yesterday 00:00:00');
-
-        // after this date no need to compute anymore
-        $cutoffDate = new \DateTime('2018-07-31 23:59:59');
-        while ($date <= $yesterday && $date <= $cutoffDate) {
-            // skip months already computed
-            if (null !== $this->getMonthly($date) && $date->format('m') !== $yesterday->format('m')) {
-                $date->setDate($date->format('Y'), $date->format('m')+1, 1);
-                continue;
-            }
-
-            // skip days already computed
-            if (null !== $this->getDaily($date) && $date != $yesterday) {
-                $date->modify('+1day');
-                continue;
-            }
-
-            $sum = $this->sum($date->format('Ymd'), $ids);
-            $redis->set('downloads:'.$date->format('Ymd'), $sum);
-
-            if ($verbose) {
-                $output->writeln('Wrote daily data for '.$date->format('Y-m-d').': '.$sum);
-            }
-
-            $nextDay = clone $date;
-            $nextDay->modify('+1day');
-            // update the monthly total if we just computed the last day of the month or the last known day
-            if ($date->format('Ymd') === $yesterday->format('Ymd') || $date->format('Ym') !== $nextDay->format('Ym')) {
-                $sum = $this->sum($date->format('Ym'), $ids);
-                $redis->set('downloads:'.$date->format('Ym'), $sum);
-
-                if ($verbose) {
-                    $output->writeln('Wrote monthly data for '.$date->format('Y-m').': '.$sum);
-                }
-            }
-
-            $date = $nextDay;
-        }
-        // TODO end delete here
-
         // fetch existing ids
         $doctrine = $this->getContainer()->get('doctrine');
         $packages = $conn->fetchAll('SELECT id FROM package ORDER BY id ASC');
@@ -144,31 +94,4 @@ class CompileStatsCommand extends ContainerAwareCommand
 
         return $sum;
     }
-
-    // TODO delete all below as well once july data is computed
-    protected function sum($date, array $ids)
-    {
-        $sum = 0;
-
-        while ($ids) {
-            $batch = array_splice($ids, 0, 500);
-            $keys = array();
-            foreach ($batch as $id) {
-                $keys[] = 'dl:'.$id.':'.$date;
-            }
-            $sum += array_sum($res = $this->redis->mget($keys));
-        }
-
-        return $sum;
-    }
-
-    protected function getMonthly(\DateTime $date)
-    {
-        return $this->redis->get('downloads:'.$date->format('Ym'));
-    }
-
-    protected function getDaily(\DateTime $date)
-    {
-        return $this->redis->get('downloads:'.$date->format('Ymd'));
-    }
 }