Skip to content

Commit

Permalink
There is no more force update..
Browse files Browse the repository at this point in the history
  • Loading branch information
karbowiak committed Oct 6, 2024
1 parent ced78bc commit ae55a90
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
10 changes: 5 additions & 5 deletions app/Commands/Updates/UpdateAlliances.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class UpdateAlliances extends ConsoleCommand
{
protected string $signature = 'update:alliances { allianceId? : Process a single allianceId } { --all } { --forceUpdate }';
protected string $signature = 'update:alliances { allianceId? : Process a single allianceId } { --all } { --updateHistory }';
protected string $description = 'Update the alliances in the database';

public function __construct(
Expand All @@ -36,10 +36,10 @@ final public function handle(): void
protected function handleSingleAlliance(): void
{
$allianceId = $this->allianceId;
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;

$this->out("Updating alliance with ID: {$allianceId}");
$this->esiData->getAllianceInfo($allianceId, $forceUpdate);
$this->esiData->getAllianceInfo($allianceId, $updateHistory);
}

/**
Expand All @@ -50,13 +50,13 @@ protected function handleAllAlliances(): void
$updatedCriteria = ['updated' => ['$lt' => new UTCDateTime(strtotime('-7 days') * 1000)]];
$allianceCount = $this->alliances->count($this->all ? [] : $updatedCriteria);
$this->out('Alliances to update: ' . $allianceCount);
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;

$progress = $this->progressBar($allianceCount);
$alliancesToUpdate = [];

foreach ($this->alliances->find($this->all ? [] : $updatedCriteria) as $alliance) {
$alliancesToUpdate[] = ['alliance_id' => $alliance['alliance_id'], 'force_update' => $forceUpdate];
$alliancesToUpdate[] = ['alliance_id' => $alliance['alliance_id'], 'update_history' => $updateHistory];
$progress->advance();
}

Expand Down
10 changes: 3 additions & 7 deletions app/Commands/Updates/UpdateCharacters.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class UpdateCharacters extends ConsoleCommand
{
protected string $signature = 'update:characters { characterId? : Process a single characterId } { --all } { --forceUpdate } { --updateHistory }';
protected string $signature = 'update:characters { characterId? : Process a single characterId } { --all } { --updateHistory }';
protected string $description = 'Update the characters in the database (Default 30 days)';

public function __construct(
Expand All @@ -38,11 +38,10 @@ final public function handle(): void
protected function handleSingleCharacter(): void
{
$characterId = (int) $this->characterId;
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;

$this->out("Updating character with ID: {$characterId}");
$this->esiData->getCharacterInfo($characterId, $forceUpdate, $updateHistory);
$this->esiData->getCharacterInfo($characterId, $updateHistory);
}

/**
Expand All @@ -53,8 +52,6 @@ protected function handleAllCharacters(): void
$updatedCriteria = ['last_modified' => ['$lt' => new UTCDateTime(strtotime('-30 days') * 1000)]];
$characterCount = $this->characters->count($this->all ? [] : $updatedCriteria);
$this->out('Characters to update: ' . $characterCount);
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;

$progress = $this->progressBar($characterCount);
$charactersToUpdate = [];
Expand All @@ -67,8 +64,7 @@ protected function handleAllCharacters(): void

foreach ($cursor as $character) {
$charactersToUpdate[] = [
'character_id' => $character['character_id'],
'force_update' => $forceUpdate
'character_id' => $character['character_id']
];

if ($this->updateHistory) {
Expand Down
10 changes: 3 additions & 7 deletions app/Commands/Updates/UpdateCorporations.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class UpdateCorporations extends ConsoleCommand
{
protected string $signature = 'update:corporations { corporationId? : Process a single corporationId } { --all } { --forceUpdate } { --updateHistory }';
protected string $signature = 'update:corporations { corporationId? : Process a single corporationId } { --all } { --updateHistory }';
protected string $description = 'Update the corporations in the database';

public function __construct(
Expand All @@ -38,11 +38,10 @@ final public function handle(): void
protected function handleSingleCorporation(): void
{
$corporationId = $this->corporationId;
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;

$this->out("Updating corporation with ID: {$corporationId}");
$this->esiData->getCorporationInfo($corporationId, $forceUpdate, $updateHistory);
$this->esiData->getCorporationInfo($corporationId, $updateHistory);
}

/**
Expand All @@ -53,8 +52,6 @@ protected function handleAllCorporations(): void
$updatedCriteria = ['updated' => ['$lt' => new UTCDateTime(strtotime('-7 days') * 1000)]];
$corporationCount = $this->corporations->count($this->all ? [] : $updatedCriteria);
$this->out('Corporations to update: ' . $corporationCount);
$forceUpdate = $this->forceUpdate ?? false;
$updateHistory = $this->updateHistory ?? false;
$progress = $this->progressBar($corporationCount);
$corporationsToUpdate = [];
$corporationsToUpdateHistory = [];
Expand All @@ -66,8 +63,7 @@ protected function handleAllCorporations(): void

foreach ($cursor as $corporation) {
$corporationsToUpdate[] = [
'corporation_id' => $corporation['corporation_id'],
'force_update' => $forceUpdate
'corporation_id' => $corporation['corporation_id']
];

if ($this->updateHistory) {
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/UpdateAlliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function __construct(
public function handle(array $data): void
{
$allianceId = $data["alliance_id"];
$forceUpdate = $data["force_update"] ?? false;
$updateHistory = $data["update_history"] ?? false;
if ($allianceId === 0) {
return;
}

$allianceData = $this->esiData->getAllianceInfo($allianceId, $forceUpdate);
$allianceData = $this->esiData->getAllianceInfo($allianceId, $updateHistory);

$this->updateMeilisearch->enqueue([
'id' => $allianceId,
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/UpdateCharacter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ public function __construct(
public function handle(array $data): void
{
$characterId = $data["character_id"];
$forceUpdate = $data["force_update"] ?? false;
$updateHistory = $data["update_history"] ?? false;
if ($characterId === 0) {
return;
}

$characterData = $this->esiData->getCharacterInfo($characterId, $forceUpdate, $updateHistory);
$characterData = $this->esiData->getCharacterInfo($characterId, $updateHistory);

$this->updateMeilisearch->enqueue([
'id' => $characterId,
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/UpdateCorporation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ public function __construct(
public function handle(array $data): void
{
$corporationId = $data["corporation_id"];
$forceUpdate = $data["force_update"] ?? false;
$updateHistory = $data["update_history"] ?? false;
if ($corporationId === 0) {
return;
}

$corporationData = $this->esiData->getCorporationInfo($corporationId, $forceUpdate, $updateHistory);
$corporationData = $this->esiData->getCorporationInfo($corporationId, $updateHistory);

$this->updateMeilisearch->enqueue([
'id' => $corporationId,
Expand Down

0 comments on commit ae55a90

Please sign in to comment.