mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Add follow seeder
This commit is contained in:
parent
dff76e70b3
commit
7d999f0995
1 changed files with 60 additions and 0 deletions
60
app/Console/Commands/SeedFollows.php
Normal file
60
app/Console/Commands/SeedFollows.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\{Follower, Profile};
|
||||
use Illuminate\Console\Command;
|
||||
use App\Jobs\FollowPipeline\FollowPipeline;
|
||||
|
||||
class SeedFollows extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'seed:follows';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Seed follows for testing';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$limit = 10000;
|
||||
|
||||
for ($i=0; $i < $limit; $i++) {
|
||||
try {
|
||||
$actor = Profile::orderByRaw('rand()')->firstOrFail();
|
||||
$target = Profile::orderByRaw('rand()')->firstOrFail();
|
||||
|
||||
$follow = new Follower;
|
||||
$follow->profile_id = $actor->id;
|
||||
$follow->following_id = $target->id;
|
||||
$follow->save();
|
||||
|
||||
FollowPipeline::dispatch($follow);
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue