mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Adds opt-in per-product scheduling alongside the existing global cron (dual-lane, fully backwards compatible). PriceGhost parity, task 5. Scheduling: - New products.refresh_interval / next_check_at / paused columns - Global lane (FetchAll on scrape_schedule) now only fetches products WITHOUT a custom interval and that aren't paused (existing behaviour preserved for current installs) - New buddy:fetch-due command runs every minute and fetches due, non-paused products WITH a custom interval, rescheduling each up-front (with jitter) so a slow queue can't re-dispatch them - Product::scheduleNextCheck() + a saving hook keep next_check_at in sync with the interval (set on assign, cleared when the interval is removed) UI: - Per-product 'Check frequency' select (5m..24h) and 'Pause checking' toggle in the product form - Bulk Pause/Resume actions, an Active/Paused table filter, and a 'Paused' badge on the product card Tests cover both fetch lanes (paused / interval / due filtering and rescheduling), the next_check_at sync hook, and the new schedule entry. Docs updated (features, products, settings). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26 lines
576 B
PHP
26 lines
576 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Services\PriceFetcherService;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
|
|
class UpdateAllPricesJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use Queueable;
|
|
|
|
public $timeout = PriceFetcherService::JOB_TIMEOUT;
|
|
|
|
public function __construct(public array $productIds = []) {}
|
|
|
|
public function handle(): void
|
|
{
|
|
PriceFetcherService::new()
|
|
->setLogging(true)
|
|
->updatePrices($this->productIds);
|
|
}
|
|
}
|