phpvms/modules/Importer/Services/Importers/FinalizeImporter.php
Nabeel S dfbaa1afd3
Fix rowmapper generator, check for fields, map users #443 (#583)
* Fix rowmapper generator, check for fields, map users #443

* Formatting

* Remove value store at the end of the import

* Update the notes for the importer about users

* Uncomment importers disabled during testing
2020-02-23 19:48:28 -05:00

69 lines
1.4 KiB
PHP

<?php
namespace Modules\Importer\Services\Importers;
use App\Models\User;
use App\Services\UserService;
use Modules\Importer\Services\BaseImporter;
class FinalizeImporter extends BaseImporter
{
/**
* 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',
],
];
}
/**
* The start method. Takes the offset to start from
*
* @param int $start
*
* @return mixed
*/
public function run($start = 0)
{
$this->findLastPireps();
$this->recalculateUserStats();
$this->clearValueStore();
}
/**
* Go through and set the last PIREP ID for the users
*/
protected function findLastPireps()
{
// TODO
}
/**
* 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);
});
}
/**
* Clear the value store of any old value mappings
*/
protected function clearValueStore()
{
$this->idMapper->clear();
}
}