-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More efficient squad updates #2 (#686)
* remove character filter observers * forward character batch processed event * add character filter update job * add filter update command to schedule seeder * styleci * chunk character filter updates * styleci --------- Co-authored-by: Crypta Eve <[email protected]>
- Loading branch information
1 parent
57f17c2
commit 8a9790a
Showing
11 changed files
with
162 additions
and
390 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SeAT | ||
* | ||
* Copyright (C) 2015 to present Leon Jacobs | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
namespace Seat\Web\Commands\Seat\Filters; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Foundation\Bus\DispatchesJobs; | ||
use Seat\Web\Jobs\UpdateCharacterFilters; | ||
|
||
class Update extends Command | ||
{ | ||
use DispatchesJobs; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'seat:filters:update'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Runs squad and character scheduling rule updates'; | ||
|
||
/** | ||
* Run the command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle(): void | ||
{ | ||
UpdateCharacterFilters::dispatch()->onQueue('high'); | ||
$this->line('Scheduled character filter updates for all 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,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SeAT | ||
* | ||
* Copyright (C) 2015 to present Leon Jacobs | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
namespace Seat\Web\Jobs; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Seat\Eveapi\Models\Character\CharacterInfo; | ||
use Seat\Web\Events\CharacterFilterDataUpdate; | ||
|
||
class UpdateCharacterFilters implements ShouldQueue | ||
{ | ||
use Queueable, InteractsWithQueue, Dispatchable; | ||
|
||
public function tags() | ||
{ | ||
return ['web', 'filters']; | ||
} | ||
|
||
/** | ||
* Go over all character and trigger a character filter update. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
// without chunking, we can run out of memory on large installs | ||
CharacterInfo::chunk(200, function ($characters) { | ||
foreach ($characters as $character){ | ||
event(new CharacterFilterDataUpdate($character)); | ||
} | ||
}); | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SeAT | ||
* | ||
* Copyright (C) 2015 to present Leon Jacobs | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
namespace Seat\Web\Listeners; | ||
|
||
use Seat\Eveapi\Events\CharacterBatchProcessed as BatchEvent; | ||
use Seat\Web\Events\CharacterFilterDataUpdate; | ||
|
||
class CharacterBatchProcessed | ||
{ | ||
public static function handle(BatchEvent $event) | ||
{ | ||
event(new CharacterFilterDataUpdate($event->character)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.