Add command for creation of jobs.

main
Giò 2024-04-13 16:11:18 +02:00
parent 9131a01b37
commit 585f3c2623
2 changed files with 37 additions and 3 deletions

View File

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use App\Scraper\Edomizil;
use App\Models\Property;
use Illuminate\Console\Command;
class scrapeCreateJobs extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'scrape:jobs';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create and dispatch jobs for scraping';
/**
* Execute the console command.
*/
public function handle()
{
Edomizil::dispatchPropertyJobs();
Edomizil::dispatchPropertyDataJobs();
}
}

View File

@ -1,14 +1,14 @@
<?php
namespace App\Jobs;
use App\Scraper\Edomizil;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ScrapeProperyData implements ShouldQueue
class ScrapePropertyData implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
@ -26,7 +26,8 @@ class ScrapeProperyData implements ShouldQueue
* Execute the job.
*/
public function handle(): void
{
{
Edomizil::scrapePropertyData($this->property);
sleep(random_int(1,20));
}
}