Refresh
This commit is contained in:
49
app/Console/Commands/UpdateFeeds.php
Executable file
49
app/Console/Commands/UpdateFeeds.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\EnqueueFeedUpdate;
|
||||
use App\Models\Feed;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateFeeds extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'feed:update';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Enqueue feeds that need update';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$oldest = now()->subMinute(config('cyca.maxAge.feed'));
|
||||
$feeds = Feed::needingUpdate($oldest)->get();
|
||||
|
||||
foreach ($feeds as $feed) {
|
||||
EnqueueFeedUpdate::dispatch($feed);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user