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>
34 lines
747 B
PHP
34 lines
747 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\PriceFetcherService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class FetchDue extends Command
|
|
{
|
|
const COMMAND = 'buddy:fetch-due';
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*/
|
|
protected $signature = self::COMMAND.' {--log : Log the price fetching}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*/
|
|
protected $description = 'Fetch prices for products that are due based on their custom check frequency';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
PriceFetcherService::new()
|
|
->setLogging((bool) $this->option('log'))
|
|
->updateDuePrices();
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|