diff --git a/src/Jobs/Character/PublicCorporationHistory.php b/src/Jobs/Character/PublicCorporationHistory.php new file mode 100644 index 00000000..0308a7c8 --- /dev/null +++ b/src/Jobs/Character/PublicCorporationHistory.php @@ -0,0 +1,91 @@ +preflighted()) return; + + $character_ids = User::doesntHave('refresh_token') + ->select('id') + ->where('id', '<>', 1) + ->get() + ->pluck('id'); + + $character_ids->each(function ($character_id) { + + $corporation_history = $this->retrieve([ + 'character_id' => $character_id, + ]); + + if ($corporation_history->isCachedLoad()) return; + + collect($corporation_history)->each(function ($corporation) use ($character_id) { + + CharacterCorporationHistory::firstOrCreate([ + 'character_id' => $character_id, + 'record_id' => $corporation->record_id, + ], [ + 'start_date' => carbon($corporation->start_date), + 'corporation_id' => $corporation->corporation_id, + 'is_deleted' => isset($corporation->is_deleted) ? $corporation->is_deleted : false, + ]); + }); + }); + + } +}