mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- fix type when filtering product by price met target. - fix the lowest price was overridden if price wasn't crawled. - fix store tabs not working - fix some european amazon using "." as thousands separator. - keep last 3 days of logs only. - added volume to .env to fix 2FA not working after restarting container - added volume for database - New Stores: - best buy New Features: - add other users to the system and manage their tokens. - add telegram notification. - add percentage drop. - robot detection for amazon ( if the system was detected as robot, it will stop executing and try the next product, the same product that was blocked will be crawled again in the next batch) Took 6 hours 50 minutes
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
|
|
use App\Console\Commands\ClearNotificationCount;
|
|
use App\Enums\StatusEnum;
|
|
use App\Jobs\CrawlProductJob;
|
|
use App\Models\ProductStore;
|
|
use App\Models\Store;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Schedule;
|
|
use Spatie\Health\Commands\ScheduleCheckHeartbeatCommand;
|
|
|
|
Schedule::call(function () {
|
|
try {
|
|
|
|
DB::table('jobs')->truncate();
|
|
|
|
Log::info("Products Schedule Started");
|
|
$stores= Store::with([
|
|
"product_stores"=>function($query){
|
|
$query->orderBy("updated_at")->limit(300);
|
|
}])
|
|
->whereHas('product_stores')
|
|
->where('status', StatusEnum::Published)
|
|
->get();
|
|
|
|
foreach ($stores as $store)
|
|
foreach ($store->product_stores as $index=>$product_store){
|
|
CrawlProductJob::dispatch($product_store->id)
|
|
->onQueue($product_store->store->slug)
|
|
->delay( now()->addSeconds($index * 5));
|
|
}
|
|
|
|
Log::info("Products Schedule Finished Successfully");
|
|
}
|
|
catch (Exception $e) {
|
|
Log::error("Couldn't Run the Product Schedule, Error: \n" . $e);
|
|
}
|
|
})->everyFiveMinutes();
|
|
|
|
|
|
Schedule::command(ClearNotificationCount::class)->dailyAt("23:59");
|
|
Schedule::command(ScheduleCheckHeartbeatCommand::class)->everyMinute();
|