server/src/app/Console/Commands/ManageHandles.php
changeset 339 766af1228b05
parent 326 226d5b17a119
child 406 cf0f23803a53
equal deleted inserted replaced
338:4a3899b6a7ed 339:766af1228b05
   107 
   107 
   108         $this->info("Adding documents handles...");
   108         $this->info("Adding documents handles...");
   109 
   109 
   110         $total = $this->documentRepository->getCount();
   110         $total = $this->documentRepository->getCount();
   111 
   111 
   112         $docs = $this->documentRepository->paginateAll($stepSize, 'page');
   112         $docs = $this->documentRepository->paginate(null, $stepSize, config('corpusparole.pagination_page_param'), 1, '_graph');
   113 
   113 
   114         $progressBar = $this->output->createProgressBar($docs->total());
   114         $progressBar = $this->output->createProgressBar($docs->total());
   115         $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% - %message%');
   115         $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% - %message%');
   116 
   116 
   117         while(!is_null($docs)) {
   117         while(!is_null($docs)) {
   118             foreach ($docs as $doc){
   118             foreach ($docs as $doc){
   119                 $this->registerHandle($doc);
   119                 $this->registerHandle($doc);
   120                 $progressBar->setMessage($doc->getId());
   120                 $progressBar->setMessage($doc->getId());
   121                 $progressBar->advance();
   121                 $progressBar->advance();
   122             }
   122             }
   123             $docs = ($docs->hasMorePages()? $this->documentRepository->paginateAll($stepSize, 'page', $docs->currentPage()+1):null);
   123             $docs = ($docs->hasMorePages()? $this->documentRepository->paginate(null, $stepSize, config('corpusparole.pagination_page_param'), $docs->currentPage()+1, '_graph'):null);
   124         }
   124         }
   125 
   125 
   126         $progressBar->finish();
   126         $progressBar->finish();
   127         $this->info("\nAdding handles completed\n");
   127         $this->info("\nAdding handles completed\n");
   128 
   128 
   129         $this->info("Removing extra handles...\n");
   129         $this->info("Removing extra handles...\n");
   130 
   130 
   131         $handles = $this->handleClient->paginateAll($this->handlePrefix, $stepSize, 'page');
   131         $handles = $this->handleClient->paginateAll($this->handlePrefix, $stepSize, config('corpusparole.pagination_page_param'));
   132 
   132 
   133         $progressBar = $this->output->createProgressBar($handles->total());
   133         $progressBar = $this->output->createProgressBar($handles->total());
   134         $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% - %message%');
   134         $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% - %message%');
   135 
   135 
   136         while(!is_null($handles)) {
   136         while(!is_null($handles)) {
   139                     $this->handleClient->deleteHandle($handle);
   139                     $this->handleClient->deleteHandle($handle);
   140                 }
   140                 }
   141                 $progressBar->setMessage($handle);
   141                 $progressBar->setMessage($handle);
   142                 $progressBar->advance();
   142                 $progressBar->advance();
   143             }
   143             }
   144             $handles = $handles->hasMorePages()?$this->handleClient->paginateAll($this->handlePrefix, $stepSize, 'page', $handles->currentPage()+1):null;
   144             $handles = $handles->hasMorePages()?$this->handleClient->paginateAll($this->handlePrefix, $stepSize, config('corpusparole.pagination_page_param'), $handles->currentPage()+1):null;
   145         }
   145         }
   146 
   146 
   147         $this->info("\nRemoving extra handles completed");
   147         $this->info("\nRemoving extra handles completed");
   148 
   148 
   149     }
   149     }