mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- Added groups, where you can set bunch of items with identified unique keys to get the lowest price on group of products. ( think of it like building your own PC, you add multiple CPUs, and GPUs and the program will notify you when the combination reaches a desired price) - Added 2FA Support to the system (Optional) - Make Sidebar collapsable - Fix name is too short which results to not be saved - Fix a bug where product can be duplicated from amazon stores
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\ScheduledClasses;
|
|
|
|
use App\Classes\GroupHelper;
|
|
use App\Enums\StatusEnum;
|
|
use App\Jobs\GetProductJob;
|
|
use App\Jobs\GroupNotifyJob;
|
|
use App\Models\Group;
|
|
use Carbon\Carbon;
|
|
|
|
class GroupSchedule
|
|
{
|
|
public function __invoke(){
|
|
|
|
|
|
$groups =Group::whereNot("status" , StatusEnum::Disabled)->get();
|
|
$index=0;
|
|
foreach ($groups as $group){
|
|
$current_price=GroupHelper::get_current_price($group);
|
|
if (
|
|
($current_price && $current_price <= $group->notify_price) &&
|
|
(!$group->snoozed_until || Carbon::create($group->snoozed_until)->isPast()) &&
|
|
(!$group->max_notifications || $group->max_notifications > $group->notifications_sent)
|
|
){
|
|
GroupNotifyJob::dispatch($group, $current_price)
|
|
->onQueue("groups")
|
|
->delay(now()->addSeconds($index * 5));
|
|
|
|
$group->update([
|
|
"notifications_sent" => $group->notifications_sent +1
|
|
]);
|
|
$index++;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|