Ejemplo n.º 1
0
 /**
  * Backfill all the groups up to user specified time/date.
  *
  * @param string $groupName
  * @param string|int $articles
  * @param string $type
  *
  * @return void
  */
 public function backfillAllGroups($groupName = '', $articles = '', $type = '')
 {
     $res = [];
     if ($groupName !== '') {
         $grp = $this->_groups->getByName($groupName);
         if ($grp) {
             $res = [$grp];
         }
     } else {
         if ($type === 'normal' || $type === '') {
             $res = $this->_groups->getActiveBackfill();
         } else {
             if ($type === 'date') {
                 $res = $this->_groups->getActiveByDateBackfill();
             }
         }
     }
     $groupCount = count($res);
     if ($groupCount > 0) {
         $counter = 1;
         $allTime = microtime(true);
         $dMessage = 'Backfilling: ' . $groupCount . ' group(s) - Using compression? ' . ($this->_compressedHeaders ? 'Yes' : 'No');
         if ($this->_debug) {
             $this->_debugging->log(get_class(), __FUNCTION__, $dMessage, Logger::LOG_INFO);
         }
         if ($this->_echoCLI) {
             $this->pdo->log->doEcho($this->pdo->log->header($dMessage), true);
         }
         $this->_binaries = new Binaries(['NNTP' => $this->_nntp, 'Echo' => $this->_echoCLI, 'Settings' => $this->pdo, 'Groups' => $this->_groups]);
         if ($articles !== '' && !is_numeric($articles)) {
             $articles = 20000;
         }
         // Loop through groups.
         foreach ($res as $groupArr) {
             if ($groupName === '') {
                 $dMessage = "Starting group " . $counter . ' of ' . $groupCount;
                 if ($this->_debug) {
                     $this->_debugging->log(get_class(), __FUNCTION__, $dMessage, Logger::LOG_INFO);
                 }
                 if ($this->_echoCLI) {
                     $this->pdo->log->doEcho($this->pdo->log->header($dMessage), true);
                 }
             }
             $this->backfillGroup($groupArr, $groupCount - $counter, $articles);
             $counter++;
         }
         $dMessage = 'Backfilling completed in ' . number_format(microtime(true) - $allTime, 2) . " seconds.";
         if ($this->_debug) {
             $this->_debugging->log(get_class(), __FUNCTION__, $dMessage, Logger::LOG_INFO);
         }
         if ($this->_echoCLI) {
             $this->pdo->log->doEcho($this->pdo->log->primary($dMessage));
         }
     } else {
         $dMessage = "No groups specified. Ensure groups are added to nZEDb's database for updating.";
         if ($this->_debug) {
             $this->_debugging->log(get_class(), __FUNCTION__, $dMessage, Logger::LOG_FATAL);
         }
         if ($this->_echoCLI) {
             $this->pdo->log->doEcho($this->pdo->log->warning($dMessage), true);
         }
     }
 }