Files
pricebuddy/app/Jobs/UpdateAllPricesJob.php
JeremyandClaude Opus 4.8 d714d43dc3 feat: per-product check intervals and pause/resume
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>
2026-06-03 08:07:58 +10:00

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