Files
YNWA Fawzy f037a936f3 Fixes:
- 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
2024-09-29 18:31:13 +04:00

53 lines
1.2 KiB
PHP

<?php
namespace App\Jobs;
use App\Models\ProductStore;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Throwable;
class CrawlProductJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 1;
/**
* Create a new job instance.
*/
public function __construct(private $product_store_id)
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
try {
$current_product_store=ProductStore::with("store")->find($this->product_store_id);
$final_class_name="App\Helpers\StoresAvailable\\" . Str::ucfirst( explode(".",$current_product_store->store->domain)[0]);
new $final_class_name($current_product_store->id);
}catch (\Exception | \Error $e){
Log::error("Job Stopped And Failed");
}
}
public function failed(?Throwable $exception): void
{
Log::error($exception);
$this->fail($exception);
$this->delete();
}
}