Add command for creation of jobs.
parent
9131a01b37
commit
585f3c2623
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue