Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/database/seeders/CcpSdeSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CcpSdeSeeder extends Seeder
/**
* @var string
*/
private const VERSION = '3118350';
private $version = '3118350';

/**
* The SDE file storage path.
Expand Down Expand Up @@ -86,8 +86,10 @@ public function run()
if (! $this->isStorageOk())
throw new DirectoryNotFoundException('Storage path is not OK. Please check permissions.');

$this->command->info('Authorised Version Found as: ' . self::VERSION);
$this->command->info('Getting latest SDE Version');
$this->getLatestSdeVersion();

$this->command->info('Authorised Version Found as: ' . $this->version);

$this->command->info('Downloading static files...');
$this->downloadStaticFiles();
Expand All @@ -96,14 +98,14 @@ public function run()
$this->call($this->seeders);
}


/**
* Download the EVE Sde from Fuzzwork and save it
* in the storage_path/sde folder.
*/
private function downloadStaticFiles()
{

$sde = sprintf('eve-online-static-data-%d-jsonl.zip', self::VERSION);
$sde = sprintf('eve-online-static-data-%d-jsonl.zip', $this->version);

$url = sprintf('https://developers.eveonline.com/static-data/tranquility/%s', $sde);
$destination = $this->storage_path . $sde;
Expand All @@ -122,6 +124,24 @@ private function downloadStaticFiles()
}
}

private function getLatestSdeVersion()
{
$result = Http::get('https://developers.eveonline.com/static-data/tranquility/latest.jsonl');
// fallback to const version
if(!$result->successful()){
$this->command->info('Unable to get latest version, using version: '. $this->version);
return;
}
$firstLine = strtok($result->body(), "\n");
$data = json_decode($firstLine, true);
if(!$data['buildNumber']){
this->command->info('Unable to get latest build version from response. using version: '. $this->version);
return;
}

$this->version = $data['buildNumber'];
}

private function extractZipWithProgress(string $zipPath, string $destination): void
{
$zip = new \ZipArchive;
Expand Down
2 changes: 1 addition & 1 deletion src/database/seeders/Sde/Ccp/InvTypesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function getSdeTableDefinition(Blueprint $table): void
{
$table->integer('typeID')->primary();
$table->integer('groupID');
$table->string('typeName', 100);
$table->string('typeName', 150);
$table->text('description')->nullable();
$table->double('mass')->nullable();
$table->double('volume')->nullable();
Expand Down