mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: cloudflare purge
This commit is contained in:
@@ -16,12 +16,13 @@ class ChampionRolesSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$roleDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/championrates.json';
|
$roleDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/championrates.json';
|
||||||
$roleData = json_decode(file_get_contents($roleDataUrl), true);
|
$roleData = json_decode(file_get_contents($roleDataUrl), true);
|
||||||
|
$changeCount = 0;
|
||||||
|
|
||||||
foreach ($roleData['data'] as $championId => $roles) {
|
foreach ($roleData['data'] as $championId => $roles) {
|
||||||
$rolesExists = ChampionRoles::where('champion_id', $championId)->first();
|
$rolesExists = ChampionRoles::where('champion_id', $championId)->first();
|
||||||
$championExists = Champion::where('champion_id', $championId)->first();
|
$championExists = Champion::where('champion_id', $championId)->first();
|
||||||
|
|
||||||
if (! $championExists) {
|
if (!$championExists) {
|
||||||
Log::info('Champion with ID ' . $championId . ' does not exist, skipping...');
|
Log::info('Champion with ID ' . $championId . ' does not exist, skipping...');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -45,11 +46,16 @@ class ChampionRolesSeeder extends Seeder
|
|||||||
if ($rolesExists && $this->hasAttributesChanged($rolesExists, $rolesAttributes)) {
|
if ($rolesExists && $this->hasAttributesChanged($rolesExists, $rolesAttributes)) {
|
||||||
Log::info('Roles for ' . $championName . ' have changed, updating...');
|
Log::info('Roles for ' . $championName . ' have changed, updating...');
|
||||||
$rolesExists->update($rolesAttributes);
|
$rolesExists->update($rolesAttributes);
|
||||||
|
$changeCount++;
|
||||||
} elseif (!$rolesExists) {
|
} elseif (!$rolesExists) {
|
||||||
Log::info('New roles detected for ' . $championName . '! Creating...');
|
Log::info('New roles detected for ' . $championName . '! Creating...');
|
||||||
ChampionRoles::create($rolesAttributes);
|
ChampionRoles::create($rolesAttributes);
|
||||||
|
$changeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($changeCount > 0) {
|
||||||
|
$this->call('cloudflare:purge');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function hasAttributesChanged($roleData, $attributes)
|
private function hasAttributesChanged($roleData, $attributes)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class ChampionSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
||||||
$championData = json_decode(file_get_contents($championDataUrl), true);
|
$championData = json_decode(file_get_contents($championDataUrl), true);
|
||||||
|
$changeCount = 0;
|
||||||
|
|
||||||
foreach ($championData as $champion) {
|
foreach ($championData as $champion) {
|
||||||
$championId = $champion['id'];
|
$championId = $champion['id'];
|
||||||
@@ -41,11 +42,16 @@ class ChampionSeeder extends Seeder
|
|||||||
if ($championExists && $this->hasAttributesChanged($championExists, $championAttributes)) {
|
if ($championExists && $this->hasAttributesChanged($championExists, $championAttributes)) {
|
||||||
Log::info('Champion ' . $champion['name'] . ' has changed, updating...');
|
Log::info('Champion ' . $champion['name'] . ' has changed, updating...');
|
||||||
$championExists->update($championAttributes);
|
$championExists->update($championAttributes);
|
||||||
} elseif (! $championExists) {
|
$changeCount++;
|
||||||
|
} elseif (!$championExists) {
|
||||||
Log::info('New champion detected! Creating ' . $champion['name'] . '...');
|
Log::info('New champion detected! Creating ' . $champion['name'] . '...');
|
||||||
Champion::create($championAttributes);
|
Champion::create($championAttributes);
|
||||||
|
$changeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($changeCount > 0) {
|
||||||
|
$this->call('cloudflare:purge');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function hasAttributesChanged($champion, $attributes)
|
private function hasAttributesChanged($champion, $attributes)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class ChampionSkinSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
||||||
$championData = json_decode(file_get_contents($championDataUrl), true);
|
$championData = json_decode(file_get_contents($championDataUrl), true);
|
||||||
|
$changeCount = 0;
|
||||||
|
|
||||||
foreach ($championData as $champion) {
|
foreach ($championData as $champion) {
|
||||||
foreach ($champion['skins'] as $skin) {
|
foreach ($champion['skins'] as $skin) {
|
||||||
@@ -52,8 +53,12 @@ class ChampionSkinSeeder extends Seeder
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Mundo is a special case, his skins often include his name in the skin name, so we need to remove it.
|
// Mundo is a special case, his skins often include his name in the skin name, so we need to remove it.
|
||||||
if (strpos($skinAttributes['skin_name'], 'Mundo Dr. Mundo') !== false) {
|
if (str_contains($skinAttributes['skin_name'], 'Mundo Dr. Mundo')) {
|
||||||
$skinAttributes['skin_name'] = str_replace('Mundo Dr. Mundo', 'Mundo', $skinAttributes['skin_name']);
|
$skinAttributes['skin_name'] = str_replace(
|
||||||
|
'Mundo Dr. Mundo',
|
||||||
|
'Mundo',
|
||||||
|
$skinAttributes['skin_name']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the skin already exists and if any attributes have changed, if so update the skin. If the skin doesn't exist, create it.
|
// Check if the skin already exists and if any attributes have changed, if so update the skin. If the skin doesn't exist, create it.
|
||||||
@@ -61,11 +66,16 @@ class ChampionSkinSeeder extends Seeder
|
|||||||
if ($skinExists && $this->hasAttributesChanged($skinExists, $skinAttributes)) {
|
if ($skinExists && $this->hasAttributesChanged($skinExists, $skinAttributes)) {
|
||||||
Log::info('Skin ' . $skin['name'] . ' ' . $champion['name'] . ' has changed, updating...');
|
Log::info('Skin ' . $skin['name'] . ' ' . $champion['name'] . ' has changed, updating...');
|
||||||
$skinExists->update($skinAttributes);
|
$skinExists->update($skinAttributes);
|
||||||
} elseif (! $skinExists) {
|
$changeCount++;
|
||||||
|
} elseif (!$skinExists) {
|
||||||
Log::info('New skin detected! Creating ' . $skin['name'] . ' ' . $champion['name'] . '...');
|
Log::info('New skin detected! Creating ' . $skin['name'] . ' ' . $champion['name'] . '...');
|
||||||
ChampionSkin::create($skinAttributes);
|
ChampionSkin::create($skinAttributes);
|
||||||
|
$changeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($changeCount > 0) {
|
||||||
|
$this->call('cloudflare:purge');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class SkinChromaSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
|
||||||
$championData = json_decode(file_get_contents($championDataUrl), true);
|
$championData = json_decode(file_get_contents($championDataUrl), true);
|
||||||
|
$changeCount = 0;
|
||||||
|
|
||||||
foreach ($championData as $champion) {
|
foreach ($championData as $champion) {
|
||||||
foreach ($champion['skins'] as $skin) {
|
foreach ($champion['skins'] as $skin) {
|
||||||
@@ -50,12 +51,17 @@ class SkinChromaSeeder extends Seeder
|
|||||||
if ($chromaExists && $this->hasAttributesChanged($chromaExists, $chromaAttributes)) {
|
if ($chromaExists && $this->hasAttributesChanged($chromaExists, $chromaAttributes)) {
|
||||||
Log::info('Updating chroma: ' . $chromaId);
|
Log::info('Updating chroma: ' . $chromaId);
|
||||||
$chromaExists->update($chromaAttributes);
|
$chromaExists->update($chromaAttributes);
|
||||||
|
$changeCount++;
|
||||||
} elseif (!$chromaExists) {
|
} elseif (!$chromaExists) {
|
||||||
Log::info('Creating chroma: ' . $chromaId);
|
Log::info('Creating chroma: ' . $chromaId);
|
||||||
SkinChroma::create($chromaAttributes);
|
SkinChroma::create($chromaAttributes);
|
||||||
|
$changeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($changeCount > 0) {
|
||||||
|
$this->call('cloudflare:purge');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user