Increase speed of processing the prices and products. Because this is getting out of hand.
This commit was merged in pull request #33.
This commit is contained in:
@@ -33,6 +33,7 @@ class ScrapeWebsite extends Command
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('Scrape products');
|
||||
$progress = new ProgressBar($output);
|
||||
$progress->start();
|
||||
$products = $this->getProducts();
|
||||
@@ -42,8 +43,25 @@ class ScrapeWebsite extends Command
|
||||
$progress->advance();
|
||||
}
|
||||
$progress->finish();
|
||||
$output->writeln('Scrape products - DONE');
|
||||
$output->writeln('');
|
||||
$output->writeln('DONE');
|
||||
|
||||
$output->writeln('Update prices');
|
||||
$products = Product::all();
|
||||
$progress->setMaxSteps(count($products));
|
||||
$progress->start();
|
||||
foreach($products as $product) {
|
||||
$product->priceCurrent = $product->newestPrice->price;
|
||||
$product->productStandardPrice = $product->newestPrice->productStandardPrice;
|
||||
$product->lowestProductPrice30Days = $product->newestPrice->lowestProductPrice30Days;
|
||||
$product->priceLowest = $product->lowestPrice->price;
|
||||
$product->save(['timestamps' => false]);
|
||||
$progress->advance();
|
||||
}
|
||||
$progress->finish();
|
||||
$output->writeln('');
|
||||
$output->writeln('Update prices - DONE');
|
||||
$output->writeln('COMMAND - DONE');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user