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:
2026-01-08 17:18:46 +01:00
parent de4915972c
commit 8e8ef8fe04
7 changed files with 67 additions and 15 deletions

View File

@@ -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;
}