Skip to content

Commit

Permalink
Merge pull request #2589 from RaiderIO/development
Browse files Browse the repository at this point in the history
Release v11.5.2 - More bugfixes
  • Loading branch information
Wotuu authored Oct 23, 2024
2 parents 4bd5c4b + 67f3383 commit dc05408
Show file tree
Hide file tree
Showing 241 changed files with 6,540 additions and 810 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
!/public/robots.txt
!/public/web.config

/resouces/assets/images/tiles
/resources/assets/images/tiles
# Generated file only used for temp output step for inclusion in compiled file
/resouces/assets/js/handlebars.js
/resouces/assets/js/precompile.js
/resources/assets/js/handlebars.js
/resources/assets/js/precompile.js
/storage/*.key
/storage/debugbar/*.json
/storage/framework/maintenance.php
Expand Down
9 changes: 7 additions & 2 deletions app/Console/Commands/Database/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Console\Commands\Database;

use App\Console\Commands\Traits\ExecutesShellCommands;
use App\Repositories\Database\ReleaseRepository;
use App\Models\Release;
use App\Repositories\Interfaces\ReleaseRepositoryInterface;
use Illuminate\Console\Command;

Expand Down Expand Up @@ -32,7 +32,12 @@ public function handle(
$release = (bool)$this->option('release');

// If we're not releasing, or we are releasing and the release asks for a backup. Do a backup by default, though, to be sure.
if (!$release || ($releaseRepository->getLatestUnreleasedRelease()?->backup_db ?? true)) {
$latestUnreleasedRelease = $releaseRepository->getLatestUnreleasedRelease();
if (!$release || ($latestUnreleasedRelease?->backup_db ?? true)) {
if ($latestUnreleasedRelease instanceof Release) {
$this->info(sprintf('Backing up MySQL database for release %d...', $latestUnreleasedRelease->id));
}

// Backup MySql database if the environment asks for it!
$backupDir = config('keystoneguru.db_backup_dir');

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Database/SeedOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function handle(
*
* @return string
*/
protected function getDatabase()
protected function getDatabase(): string
{
$database = $this->input->getOption('database');

Expand Down
58 changes: 31 additions & 27 deletions app/Console/Commands/Scheduler/Discover/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

use App\Console\Commands\Scheduler\SchedulerCommand;
use App\Jobs\RefreshDiscoverCache;
use App\Models\Dungeon;
use App\Models\Expansion;
use App\Models\GameServerRegion;
use App\Models\Season;
use App\Service\DungeonRoute\DiscoverServiceInterface;
use App\Service\Expansion\ExpansionServiceInterface;

Expand Down Expand Up @@ -49,11 +48,23 @@ public function handle(DiscoverServiceInterface $discoverService, ExpansionServi
// Disable cache so that we may refresh it
$discoverService = $discoverService->withCache(false);

$expansions = [
$expansionService->getCurrentExpansion(),
$expansionService->getNextExpansion(),
];

// Refresh caches for all categories
foreach (Expansion::with(['dungeons'])->active()->get() as $expansion) {
foreach ($expansions as $expansion) {
// Next expansion is usually going to be empty, unless we're actively approaching a new expansion
if ($expansion === null) {
continue;
}

/** @var Expansion $expansion */
$this->info(sprintf('- %s', $expansion->shortname));

$expansion->load('dungeons');

// First we will parse all pages for a certain expansion (just let me see all dungeons for an expansion)
$discoverService = $discoverService->withExpansion($expansion);
$discoverService->popular();
Expand All @@ -62,43 +73,36 @@ public function handle(DiscoverServiceInterface $discoverService, ExpansionServi
$discoverService->popularUsers();

// In theory this can lead to cache misses when we're in the process of switching seasons, but I'll take it
$currentSeason = $expansionService->getCurrentSeason($expansion, GameServerRegion::getUserOrDefaultRegion());

foreach ($expansion->dungeons()->active()->get() as $dungeon) {
/** @var Dungeon $dungeon */
$this->info(sprintf('-- Dungeon %s', $dungeon->key));

$discoverService->popularByDungeon($dungeon);
$discoverService->newByDungeon($dungeon);
$discoverService->popularUsersByDungeon($dungeon);

foreach ($currentSeason?->affixGroups ?? [] as $affixGroup) {
// $this->info(sprintf('--- AffixGroup %s', $affixgroup->getTextAttribute()));
$discoverService->popularByDungeonAndAffixGroup($dungeon, $affixGroup);
$discoverService->newByDungeonAndAffixGroup($dungeon, $affixGroup);
$discoverService->popularUsersByDungeonAndAffixGroup($dungeon, $affixGroup);
}
}
/** @var Season[] $seasons */
$seasons = [
$expansionService->getCurrentSeason($expansion),
$expansionService->getNextSeason($expansion),
];

// Now, if this expansion has a current season, re-build all the pages as if they're viewing the
// :expansion/season/:season page. Remember, an expansion's season can have dungeons from any other expansion into it
// The cache key changes when you assign a season to the DiscoverService so those pages need to be cached again
if ($currentSeason !== null) {
foreach ($currentSeason->affixGroups ?? [] as $affixGroup) {
foreach ($seasons as $season) {
// May be null if we're in between seasons, or the next season is not known yet
if ($season === null) {
continue;
}
$this->info(sprintf('- %s', $season->name));

foreach ($season->affixGroups ?? [] as $affixGroup) {
$this->info(sprintf('-- AffixGroup %s', $affixGroup->getTextAttribute()));
$discoverService->popularGroupedByDungeonByAffixGroup($affixGroup);
}

$this->info(sprintf('-- %s', $currentSeason->name));
$discoverService = $discoverService->withSeason($currentSeason);
foreach ($currentSeason->dungeons()->active()->get() as $dungeon) {
$this->info(sprintf('--- Dungeon %s', $dungeon->key));
$discoverService = $discoverService->withSeason($season);
foreach ($season->dungeons()->active()->get() as $dungeon) {
$this->info(sprintf('-- Dungeon %s', $dungeon->key));

$discoverService->popularByDungeon($dungeon);
$discoverService->newByDungeon($dungeon);
$discoverService->popularUsersByDungeon($dungeon);

foreach ($currentSeason->affixGroups ?? [] as $affixGroup) {
foreach ($season->affixGroups ?? [] as $affixGroup) {
$this->info(sprintf('--- AffixGroup %s', $affixGroup->getTextAttribute()));
$discoverService->popularGroupedByDungeonByAffixGroup($affixGroup);
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ public function htmlsearchcategory(Request $request, string $category, DiscoverS

/**
* @throws AuthorizationException
* @throws Exception
*/
public function store(
AjaxDungeonRouteSubmitFormRequest $request,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxNpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AjaxNpcController extends Controller
public function delete(Request $request)
{
try {
/** @var \App\Models\Npc\Npc $npc */
/** @var Npc $npc */
$npc = Npc::findOrFail($request->get('id'));

if ($npc->delete()) {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Traits/ChangesMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function mappingChanged(?MappingModelInterface $beforeModel, ?MappingMode
throw new Exception('Must have at least a $beforeModel OR $afterModel');
}

(new MappingChangeLog([
MappingChangeLog::create([
'dungeon_id' => $beforeModel?->getDungeonId() ?? $afterModel->getDungeonId(),
'model_id' => $beforeModel?->id ?? $afterModel->id,
'model_class' => ($beforeModel ?? $afterModel)::class,
'before_model' => $beforeModel !== null ? json_encode($beforeModel->toArray()) : null,
'after_model' => $afterModel !== null ? json_encode($afterModel->toArray()) : null,
]))->save();
]);
}
}
32 changes: 21 additions & 11 deletions app/Logic/CombatLog/CombatLogEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ class CombatLogEntry
{
public const DATE_FORMATS = [
'm/d H:i:s.v',
'm/d/Y H:i:s.v-1',
'm/d/Y H:i:s.v-1', // These are all the timezones that are used in the combat log
'm/d/Y H:i:s.v-2',
'm/d/Y H:i:s.v-3',
'm/d/Y H:i:s.v-4', // I don't know what the -4 stands for - assuming timezone? There's no thingy for it though
'm/d/Y H:i:s.v-4',
'm/d/Y H:i:s.v-5',
'm/d/Y H:i:s.v-6',
'm/d/Y H:i:s.v-7',
'm/d/Y H:i:s.v-8',
'm/d/Y H:i:s.v-9',
'm/d/Y H:i:s.v1', // I don't know what the 1-9 stands for
'm/d/Y H:i:s.v-10',
'm/d/Y H:i:s.v-11',
'm/d/Y H:i:s.v-12',
'm/d/Y H:i:s.v-13',
'm/d/Y H:i:s.v-14',
'm/d/Y H:i:s.v0',
'm/d/Y H:i:s.v1',
'm/d/Y H:i:s.v2',
'm/d/Y H:i:s.v3',
'm/d/Y H:i:s.v4',
Expand All @@ -34,7 +40,11 @@ class CombatLogEntry
'm/d/Y H:i:s.v7',
'm/d/Y H:i:s.v8',
'm/d/Y H:i:s.v9',
'm/d/Y H:i:s.v0',
'm/d/Y H:i:s.v10',
'm/d/Y H:i:s.v11',
'm/d/Y H:i:s.v12',
'm/d/Y H:i:s.v13',
'm/d/Y H:i:s.v14',
];

private const RAW_EVENT_IGNORE = [
Expand All @@ -45,13 +55,13 @@ class CombatLogEntry
'COMBAT_LOG_VERSION,20,ADVANCED_LOG_ENABLED,1,BUILD_VERSION,11.0.0,PROJECT_ID,1',
];

/** @var int|null Remembers what date format was last found in the combat log and uses that for subsequent format parses first. */
private static ?int $previousDateFormat = null;

private ?Carbon $parsedTimestamp = null;

private ?BaseEvent $parsedEvent = null;

/** @var int|null Remembers what date format was last found in the combat log and uses that for subsequent format parses first. */
private ?int $previousDateFormat = null;

public function __construct(private readonly string $rawEvent)
{
}
Expand Down Expand Up @@ -140,24 +150,24 @@ private function parseTimestamp(string $timestamp): Carbon
$parsedTimestamp = null;

// If we had a previous date format, try to parse with that format first
if ($this->previousDateFormat !== null) {
if (self::$previousDateFormat !== null) {
try {
return Carbon::createFromFormat(self::DATE_FORMATS[$this->previousDateFormat], $timestamp);
return Carbon::createFromFormat(self::DATE_FORMATS[self::$previousDateFormat], $timestamp);
} catch (InvalidFormatException $invalidFormatException) {
// Ignore, we'll try the other formats
}
}

foreach (self::DATE_FORMATS as $key => $dateFormat) {
// Don't double-check if it's not needed
if ($key === $this->previousDateFormat) {
if ($key === self::$previousDateFormat) {
continue;
}

try {
$parsedTimestamp = Carbon::createFromFormat($dateFormat, $timestamp);

$this->previousDateFormat = $key;
self::$previousDateFormat = $key;
} catch (InvalidFormatException $invalidFormatException) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Logic/SimulationCraft/RaidEventPull.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function calculateDelay(KillZone $killZone, LatLng $previousKillLocation)
// Convert the location of the pack to in-game location, and then determine the delay according to floor x-y
$killLocation = $killZone->getKillLocation();
// No enemies killed, no location, no pull, no delay
if ($killLocation === null) {
if ($killLocation === null || $previousKillLocation->getFloor() === null || $killLocation->getFloor() === null) {
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions app/Models/DungeonConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ trait DungeonConstants
public const DUNGEON_ZUL_AMAN = 'zul_aman';
public const DUNGEON_ZUL_GURUB = 'zul_gurub';

// Cataclysm raid
public const RAID_FIRELANDS = 'firelands';
public const RAID_DRAGON_SOUL = 'dragonsoul';

// Mists of Pandaria
public const DUNGEON_GATE_OF_THE_SETTING_SUN = 'gate_of_the_setting_sun';
public const DUNGEON_MOGU_SHAN_PALACE = 'mogu_shan palace';
Expand Down
8 changes: 6 additions & 2 deletions app/Models/Expansion.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ public function timewalkingEvent(): HasOne
return $this->hasOne(TimewalkingEvent::class);
}

public function currentSeason(GameServerRegion $gameServerRegion): ?Season
public function currentSeason(?GameServerRegion $gameServerRegion = null): ?Season
{
$gameServerRegion ??= GameServerRegion::getUserOrDefaultRegion();

if ($this->currentSeasonCache === null) {
$this->currentSeasonCache = collect();
}
Expand All @@ -140,8 +142,10 @@ public function currentSeason(GameServerRegion $gameServerRegion): ?Season
return $season;
}

public function nextSeason(GameServerRegion $gameServerRegion): ?Season
public function nextSeason(?GameServerRegion $gameServerRegion = null): ?Season
{
$gameServerRegion ??= GameServerRegion::getUserOrDefaultRegion();

if ($this->nextSeasonCache === null) {
$this->nextSeasonCache = collect();
}
Expand Down
16 changes: 7 additions & 9 deletions app/Models/GameServerRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ class GameServerRegion extends CacheModel
public $timestamps = false;

public const AMERICAS = 'us';

public const EUROPE = 'eu';

public const CHINA = 'cn';

public const TAIWAN = 'tw';

public const KOREA = 'kr';
public const EUROPE = 'eu';
public const CHINA = 'cn';
public const TAIWAN = 'tw';
public const KOREA = 'kr';

public const DEFAULT_REGION = GameServerRegion::AMERICAS;

Expand Down Expand Up @@ -69,6 +65,8 @@ public static function getUserOrDefaultRegion(): GameServerRegion
/** @var CacheServiceInterface $cacheService */
$cacheService = App::make(CacheServiceInterface::class);

return $cacheService->remember('default_region', static fn() => GameServerRegion::where('short', self::DEFAULT_REGION)->first());
return $cacheService->remember('default_region',
static fn() => GameServerRegion::where('short', self::DEFAULT_REGION)->first()
);
}
}
2 changes: 2 additions & 0 deletions app/Models/GameVersion/GameVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class GameVersion extends CacheModel
public const GAME_VERSION_WRATH = 'wotlk';
public const GAME_VERSION_CLASSIC_ERA = 'classic';
public const GAME_VERSION_BETA = 'beta';
public const GAME_VERSION_CATA = 'cata';

public const ALL = [
self::GAME_VERSION_RETAIL => 1,
self::GAME_VERSION_CLASSIC_ERA => 2,
self::GAME_VERSION_WRATH => 3,
self::GAME_VERSION_BETA => 4,
self::GAME_VERSION_CATA => 5,
];

/**
Expand Down
9 changes: 8 additions & 1 deletion app/Models/Mapping/MappingChangeLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @property string $model_class
* @property string $before_model
* @property string|null $after_model
*
* @property Carbon $updated_at
* @property Carbon $created_at
*
Expand All @@ -25,7 +26,13 @@ class MappingChangeLog extends Model
use HasGenericModelRelation;
use SeederModel;

protected $fillable = ['dungeon_id', 'model_id', 'model_class', 'before_model', 'after_model'];
protected $fillable = [
'dungeon_id',
'model_id',
'model_class',
'before_model',
'after_model'
];

public function shouldSynchronize(MappingCommitLog $mostRecentMappingCommitLog): bool
{
Expand Down
Loading

0 comments on commit dc05408

Please sign in to comment.