-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
4,280 additions
and
4,297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Jobs\CalculateTraitRaritiesForCollection; | ||
use App\Models\Collection; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Bus; | ||
|
||
class CalculateCollectionTraitRarities extends Command | ||
{ | ||
use InteractsWithCollections; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'collections:calculate-trait-rarities {--start=} {--limit=} {--collection-id=}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Calculate the trait rarities for collections'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): int | ||
{ | ||
$start = $this->option('start'); | ||
$limit = $this->option('limit'); | ||
|
||
if ($start !== null) { | ||
$collections = Collection::query() | ||
->withAcceptableSupply() | ||
->select('collections.*') | ||
->withoutSpamContracts() | ||
->where('id', '>=', (int) $start) | ||
->when($limit !== null, fn ($q) => $q->limit((int) $limit)) | ||
->orderBy('id', 'asc') | ||
->get(); | ||
|
||
$first = $collections->first(); | ||
$last = $collections->last(); | ||
|
||
Bus::batch($collections->mapInto(CalculateTraitRaritiesForCollection::class)) | ||
->name('Calculating rarities for collection IDs '.$first->id.' to '.$last->id) | ||
->dispatch(); | ||
|
||
$this->info('Starting from ID: '.$first->id.' to ID '.$last->id.' collections (inclusive). Total: '.$collections->count()); | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
||
$queryCallback = fn ($query) => $query->withAcceptableSupply(); | ||
|
||
$this->forEachCollection(function ($collection) { | ||
CalculateTraitRaritiesForCollection::dispatch($collection); | ||
}, $queryCallback); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.