2019-11-27 22:19:20 +08:00
|
|
|
<?php
|
|
|
|
|
2019-12-02 22:57:35 +08:00
|
|
|
namespace Modules\Installer\Services\Importer\Importers;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Services\UserService;
|
2019-12-02 22:57:35 +08:00
|
|
|
use Modules\Installer\Services\Importer\BaseImporter;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
2019-12-02 22:57:35 +08:00
|
|
|
class FinalizeImporter extends BaseImporter
|
2019-11-27 22:19:20 +08:00
|
|
|
{
|
2019-12-02 22:57:35 +08:00
|
|
|
/**
|
|
|
|
* Returns a default manifest just so this step gets run
|
|
|
|
*/
|
|
|
|
public function getManifest(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'importer' => get_class($this),
|
|
|
|
'start' => 0,
|
|
|
|
'end' => 1,
|
|
|
|
'message' => 'Finalizing import',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2019-11-27 22:19:20 +08:00
|
|
|
|
2019-12-02 22:57:35 +08:00
|
|
|
/**
|
|
|
|
* The start method. Takes the offset to start from
|
|
|
|
*
|
|
|
|
* @param int $start
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2019-11-27 22:19:20 +08:00
|
|
|
public function run($start = 0)
|
|
|
|
{
|
|
|
|
$this->findLastPireps();
|
|
|
|
$this->recalculateUserStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go through and set the last PIREP ID for the users
|
|
|
|
*/
|
|
|
|
protected function findLastPireps()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalculate all of the user stats
|
|
|
|
*/
|
|
|
|
protected function recalculateUserStats()
|
|
|
|
{
|
|
|
|
$this->comment('--- RECALCULATING USER STATS ---');
|
|
|
|
$userSvc = app(UserService::class);
|
|
|
|
|
|
|
|
User::all()->each(function ($user) use ($userSvc) {
|
|
|
|
$userSvc->recalculateStats($user);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|