diff --git a/src/Commands/UpgradeFits.php b/src/Commands/UpgradeFits.php index 4da5552..98e795c 100644 --- a/src/Commands/UpgradeFits.php +++ b/src/Commands/UpgradeFits.php @@ -1,114 +1,111 @@ -info("Finding fits to upgrade!"); - - $oldFits = OldFitting::all(); - $c = count($oldFits); - - $this->info("Found " . $c . " fits to process"); - - $bar = $this->getProgressBar($c); - $failedUpgrades = 0; - - $mapping = []; - - foreach ($oldFits as $oldFit) { - try { // If a fit fails then we just add it to a list of errors. - $f = Fitting::createFromEve($oldFit->eftfitting); - $mapping[$oldFit->id] = $f->fitting_id; - } catch (Exception $e) { - Log::error(['fit' => $oldFit->eftfitting, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString()]); - $failedUpgrades += 1; - } - $bar->advance(); - } - - $bar->finish(); - $this->line(''); - - $this->info('Fitting Migration Complete!'); - $this->info('Success: ' . $c - $failedUpgrades); - $this->warn('Failure : ' . $failedUpgrades); - - $this->line(''); - - - $this->info("Updating Doctrine Fitting Mapping!"); - $oldDocs = OldDoctrine::all(); - $bar = $this->getProgressBar(count($oldDocs)); - - foreach( $oldDocs as $oldDoc){ - $newDoc = Doctrine::create([ - 'name' => $oldDoc->name, - ]); - foreach ($oldDoc->fittings()->get() as $oldFit) { - $newDoc->fittings()->attach($mapping[$oldFit->id]); - } - $bar->advance(); - - } - - $bar->finish(); - $this->line(''); - - $this->info('Doctrine Migration Complete!'); - - } - - - /** - * Get a new progress bar to display based on the - * amount of iterations we expect to use. - * - * @param $iterations - * @return \Symfony\Component\Console\Helper\ProgressBar - */ - public function getProgressBar($iterations) - { - - $bar = $this->output->createProgressBar($iterations); - - $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% %memory:6s%'); - - return $bar; - } -} +info('Finding fits to upgrade!'); + + $oldFits = OldFitting::all(); + $c = count($oldFits); + + $this->info('Found ' . $c . ' fits to process'); + + $bar = $this->getProgressBar($c); + $failedUpgrades = 0; + + $mapping = []; + + foreach ($oldFits as $oldFit) { + try { // If a fit fails then we just add it to a list of errors. + $f = Fitting::createFromEve($oldFit->eftfitting); + $mapping[$oldFit->id] = $f->fitting_id; + } catch (Exception $e) { + Log::error(['fit' => $oldFit->eftfitting, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString()]); + $failedUpgrades += 1; + } + $bar->advance(); + } + + $bar->finish(); + $this->line(''); + + $this->info('Fitting Migration Complete!'); + $this->info('Success: ' . $c - $failedUpgrades); + $this->warn('Failure : ' . $failedUpgrades); + + $this->line(''); + + $this->info('Updating Doctrine Fitting Mapping!'); + $oldDocs = OldDoctrine::all(); + $bar = $this->getProgressBar(count($oldDocs)); + + foreach($oldDocs as $oldDoc){ + $newDoc = Doctrine::create([ + 'name' => $oldDoc->name, + ]); + foreach ($oldDoc->fittings()->get() as $oldFit) { + $newDoc->fittings()->attach($mapping[$oldFit->id]); + } + $bar->advance(); + + } + + $bar->finish(); + $this->line(''); + + $this->info('Doctrine Migration Complete!'); + + } + + /** + * Get a new progress bar to display based on the + * amount of iterations we expect to use. + * + * @param $iterations + * @return \Symfony\Component\Console\Helper\ProgressBar + */ + public function getProgressBar($iterations) + { + + $bar = $this->output->createProgressBar($iterations); + + $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% %memory:6s%'); + + return $bar; + } +} diff --git a/src/FittingServiceProvider.php b/src/FittingServiceProvider.php index ca385cf..1d27326 100644 --- a/src/FittingServiceProvider.php +++ b/src/FittingServiceProvider.php @@ -2,8 +2,8 @@ namespace CryptaTech\Seat\Fitting; -use Seat\Services\AbstractSeatPlugin; use CryptaTech\Seat\Fitting\Commands\UpgradeFits; +use Seat\Services\AbstractSeatPlugin; class FittingServiceProvider extends AbstractSeatPlugin { @@ -21,7 +21,7 @@ public function boot() $this->publishes( [ - __DIR__ . '/Config/fitting.exportlinks.php' => config_path('fitting.exportlinks.php') + __DIR__ . '/Config/fitting.exportlinks.php' => config_path('fitting.exportlinks.php'), ], ['config', 'seat'] ); @@ -36,7 +36,7 @@ public function boot() */ public function add_routes() { - if (!$this->app->routesAreCached()) { + if (! $this->app->routesAreCached()) { include __DIR__ . '/Http/routes.php'; } } diff --git a/src/Helpers/CalculateEft.php b/src/Helpers/CalculateEft.php index 6efc6ab..b1d5a5f 100644 --- a/src/Helpers/CalculateEft.php +++ b/src/Helpers/CalculateEft.php @@ -2,14 +2,13 @@ namespace CryptaTech\Seat\Fitting\Helpers; +use CryptaTech\Seat\Fitting\Models\FittingItem; use Seat\Eveapi\Models\Sde\DgmTypeAttribute; use Seat\Eveapi\Models\Sde\InvType; -use CryptaTech\Seat\Fitting\Models\FittingItem; - // There are some large performance gains to be had in this file... Simply through letting the DB do all the work for us. // However until such a time that pepole complain about speed, or I get bored, I will not be updating this. -// The one exception is probably the Doctrine Report is too slow... Anyways.. +// The one exception is probably the Doctrine Report is too slow... Anyways.. // Also need to replace the dogma section. @@ -24,7 +23,7 @@ trait CalculateEft public function calculate($fitting) { $items = collect($fitting->fitItems->all()); - $types = $items->map(function (FittingItem $v, $k){ + $types = $items->map(function (FittingItem $v, $k) { return $v->type_id; })->unique(); $this->getReqSkillsByTypeIDs($types); @@ -36,7 +35,7 @@ public function calculate($fitting) public function calculateIndividual(int $typeID) { $this->getReqSkillsByTypeIDs([$typeID]); - + return $this->getSkillNames($this->requiredSkills); } @@ -124,7 +123,7 @@ private function getReqSkillsByTypeIDs($typeIDs) $attributeids = array_merge(array_keys(self::REQ_SKILLS_ATTR_LEVELS), array_values(self::REQ_SKILLS_ATTR_LEVELS)); foreach ($typeIDs as $type) { - if (gettype($type) == "array") + if (gettype($type) == 'array') $type = $type['typeID']; $res = DgmTypeAttribute::where('typeid', $type)->wherein('attributeID', $attributeids)->get(); diff --git a/src/Models/OldDoctrine.php b/src/Models/OldDoctrine.php index 5125830..7a5935f 100644 --- a/src/Models/OldDoctrine.php +++ b/src/Models/OldDoctrine.php @@ -16,5 +16,4 @@ public function fittings() { return $this->belongsToMany(OldFitting::class, 'seat_doctrine_fitting', 'doctrine_id', 'fitting_id'); } - } diff --git a/src/Models/Sde/DgmTypeEffect.php b/src/Models/Sde/DgmTypeEffect.php index 4950f71..4e446e6 100644 --- a/src/Models/Sde/DgmTypeEffect.php +++ b/src/Models/Sde/DgmTypeEffect.php @@ -1,6 +1,5 @@