From c23fecdb2fceca036142cccdfffd898778f2a3fc Mon Sep 17 00:00:00 2001 From: Herpaderpaldent Date: Thu, 17 Jan 2019 20:03:41 +0100 Subject: [PATCH 1/2] Introduce public corporation history updater --- .../Character/PublicCorporationHistory.php | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/Jobs/Character/PublicCorporationHistory.php diff --git a/src/Jobs/Character/PublicCorporationHistory.php b/src/Jobs/Character/PublicCorporationHistory.php new file mode 100644 index 00000000..bf1d1a61 --- /dev/null +++ b/src/Jobs/Character/PublicCorporationHistory.php @@ -0,0 +1,92 @@ +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, + ]); + }); + }); + + + } +} From 0b65c38c2875222a5d6c3f101d6466e760d67bda Mon Sep 17 00:00:00 2001 From: Herpaderp Aldent Date: Thu, 17 Jan 2019 19:29:05 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Jobs/Character/PublicCorporationHistory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Jobs/Character/PublicCorporationHistory.php b/src/Jobs/Character/PublicCorporationHistory.php index bf1d1a61..0308a7c8 100644 --- a/src/Jobs/Character/PublicCorporationHistory.php +++ b/src/Jobs/Character/PublicCorporationHistory.php @@ -87,6 +87,5 @@ public function handle() }); }); - } }