Skip to content

Commit

Permalink
Increase fetch task
Browse files Browse the repository at this point in the history
  • Loading branch information
Kejax committed Mar 27, 2024
1 parent f900fa2 commit b833ae3
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\PlanetHistory;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Http;

class Kernel extends ConsoleKernel
Expand All @@ -19,37 +20,9 @@ protected function schedule(Schedule $schedule): void
// $schedule->command('inspire')->hourly();
$schedule->call(function() {

// Get current War ID
$warIdRequest = Http::get('https://api.live.prod.thehelldiversgame.com/api/WarSeason/current/'); // TODO
Artisan::call('fetch');

$currentWarId = 801; // TODO

$planetRequest = Http::get('https://api.live.prod.thehelldiversgame.com/api/WarSeason/801/Status');

if ($planetRequest->successful()) {
$data = $planetRequest->json();

foreach ($data['planetStatus'] as $planet) {

$planet['warId'] = $currentWarId;

$planetModel = Planet::firstOrNew(['index' => $planet['index']]);
$planetModel->fill($planet);
$planetModel->save();

$history = PlanetHistory::orderBy('updated_at', 'DESC')->where('index', $planet['index'])->first();

if ($history && $history->toArray() == $planet) {
$history->touch();
} else {
PlanetHistory::create($planet);
}

}

}

})->everyThirtyMinutes();
})->everyFifteenMinutes();
}

/**
Expand Down

0 comments on commit b833ae3

Please sign in to comment.