Commenting code

This commit is contained in:
ilumos 2017-08-16 15:19:42 +01:00
parent 06b882a9b0
commit ddc0670f6b
2 changed files with 12 additions and 9 deletions

View file

@ -1,25 +1,27 @@
#!/usr/bin/env php
<?php
// Import Laravel modules
use Illuminate\Console\Application;
use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
use Illuminate\Database\Capsule\Manager as Capsule;
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\UpdateAppList;
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\SearchApps;
// Import available commands
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps};
use Zeropingheroes\LancacheAutofill\Console\Commands\CreateDatabase;
// Load Composer's autoloader
if (file_exists($a = __DIR__.'/../../autoload.php')) {
require_once $a;
} else {
require_once __DIR__.'/vendor/autoload.php';
}
// Set up the app
// Set up the console app
$app = new Application(new Container, new Dispatcher, '5.4');
// Set up the database
// Set up the SQLite database connection
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
@ -28,9 +30,10 @@ $capsule->addConnection([
]);
$capsule->setAsGlobal();
// Add commands
// Make commands available
$app->add(new CreateDatabase);
$app->add(new UpdateAppList);
$app->add(new SearchApps);
$app->add(new CreateDatabase);
// Run the console app
$app->run();

View file

@ -54,22 +54,22 @@ class UpdateAppList extends Command
$apps = $response['applist']['apps'];
// Laravel's SQLite driver can only insert a maximum of 500 records
// at a time in one compound INSERT statements, so we chunk the list
// of ~50,000 apps into chunks of 500
$appsChunked = array_chunk($apps, 500);
$bar = $this->output->createProgressBar(count($appsChunked));
$bar->setFormat("%bar% %percent%%");
$this->info('Inserting records into database');
foreach($appsChunked as $appChunk)
{
Capsule::table('steam_apps')->insert($appChunk);
$bar->advance();
}
$bar->finish();
$this->info(PHP_EOL . 'Done');
}
}