Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Jan 24, 2025
2 parents 9abbd1e + d4f88d2 commit 6a2d3d1
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 29 deletions.
32 changes: 19 additions & 13 deletions app/Http/Resources/Dungeon/DungeonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Resources\Floor\FloorResource;
use App\Models\Dungeon;
use App\Models\Floor\Floor;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
Expand All @@ -20,6 +21,7 @@
* @OA\Property(type="integer",property="mapId",example="2652",description="The map ID of the dungeon. Found on https://wago.tools/db2/Map")
* @OA\Property(type="integer",property="instanceId",example="1269",description="The instance ID of the dungeon. Found on https://wago.tools/db2/JournalInstance")
* @OA\Property(type="integer",property="challengeModeId",example="501",description="The challenge mode ID of the dungeon. Found on https://wago.tools/db2/MapChallengeMode")
* @OA\Property(type="boolean",property="raid",example="0",description="True if this dungeon is a raid")
* @OA\Property(type="boolean",property="speedrunEnabled",example="0",description="Whether speedrun is enabled for this dungeon")
* @OA\Property(type="boolean",property="speedrunDifficulty10ManEnabled",example="0",description="Whether 10-man difficulty is enabled for speedrunning")
* @OA\Property(type="boolean",property="speedrunDifficulty25ManEnabled",example="0",description="Whether 25-man difficulty is enabled for speedrunning")
Expand All @@ -37,19 +39,23 @@ class DungeonResource extends JsonResource
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'expansion' => $this->expansion->shortname,
'name' => __($this->name, [], 'en_US'),
'slug' => $this->slug,
'key' => $this->key,
'zoneId' => $this->zone_id,
'mapId' => $this->map_id,
'instanceId' => $this->instance_id,
'challengeModeId' => $this->challenge_mode_id,
'speedrunEnabled' => $this->speedrun_enabled,
'floors' => $this->floors->map(
static fn($floor) => new FloorResource($floor)
)->toArray(),
'id' => $this->id,
'expansion' => $this->expansion->shortname,
'name' => __($this->name, [], 'en_US'),
'slug' => $this->slug,
'key' => $this->key,
'zoneId' => $this->zone_id,
'mapId' => $this->map_id,
'instanceId' => $this->instance_id,
'challengeModeId' => $this->challenge_mode_id,
'raid' => $this->raid,
'speedrunEnabled' => $this->speedrun_enabled,
'speedrunDifficulty10ManEnabled' => $this->speedrun_difficulty_10_man_enabled,
'speedrunDifficulty25ManEnabled' => $this->speedrun_difficulty_25_man_enabled,
'floors' => $this->floors
->filter(static fn(Floor $floor) => !$floor->facade)
->map(static fn(Floor $floor) => new FloorResource($floor))
->toArray(),
];
}
}
6 changes: 3 additions & 3 deletions app/Providers/KeystoneGuruServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
use App\Service\Patreon\PatreonApiServiceInterface;
use App\Service\Patreon\PatreonService;
use App\Service\Patreon\PatreonServiceInterface;
use App\Service\RaiderIO\RaiderIOApiService;
use App\Service\RaiderIO\RaiderIOApiServiceInterface;
use App\Service\RaiderIO\RaiderIOKeystoneGuruApiService;
use App\Service\ReadOnlyMode\ReadOnlyModeService;
use App\Service\ReadOnlyMode\ReadOnlyModeServiceInterface;
use App\Service\Reddit\RedditApiService;
Expand Down Expand Up @@ -207,8 +207,8 @@ public function register(): void
$this->app->bind(WowToolsServiceInterface::class, WowToolsService::class);
$this->app->bind(AdProviderServiceInterface::class, AdProviderService::class);
$this->app->bind(WowheadServiceInterface::class, WowheadService::class);
// $this->app->bind(RaiderIOApiServiceInterface::class, RaiderIOApiService::class);
$this->app->bind(RaiderIOApiServiceInterface::class, RaiderIOKeystoneGuruApiService::class);
$this->app->bind(RaiderIOApiServiceInterface::class, RaiderIOApiService::class);
// $this->app->bind(RaiderIOApiServiceInterface::class, RaiderIOKeystoneGuruApiService::class);
$this->app->bind(CloudflareServiceInterface::class, CloudflareService::class);

// Depends on CombatLogService, SeasonService, WowheadService
Expand Down
7 changes: 6 additions & 1 deletion app/Providers/LoggingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use App\Http\Middleware\Logging\DebugInfoContextLoggerLogging;
use App\Http\Middleware\Logging\DebugInfoContextLoggerLoggingInterface;
use App\Jobs\Logging\ProcessRouteFloorThumbnailCustomLogging;
use App\Jobs\Logging\ProcessRouteFloorThumbnailLogging;
use App\Jobs\Logging\ProcessRouteFloorThumbnailCustomLoggingInterface;
use App\Jobs\Logging\ProcessRouteFloorThumbnailLogging;
use App\Jobs\Logging\ProcessRouteFloorThumbnailLoggingInterface;
use App\Service\AffixGroup\Logging\AffixGroupEaseTierServiceLogging;
use App\Service\AffixGroup\Logging\AffixGroupEaseTierServiceLoggingInterface;
Expand Down Expand Up @@ -76,6 +76,8 @@
use App\Service\Patreon\Logging\PatreonApiServiceLoggingInterface;
use App\Service\Patreon\Logging\PatreonServiceLogging;
use App\Service\Patreon\Logging\PatreonServiceLoggingInterface;
use App\Service\RaiderIO\Logging\RaiderIOApiServiceLogging;
use App\Service\RaiderIO\Logging\RaiderIOApiServiceLoggingInterface;
use App\Service\Spell\Logging\SpellServiceLogging;
use App\Service\Spell\Logging\SpellServiceLoggingInterface;
use App\Service\StructuredLogging\Logging\StructuredLoggingServiceLogging;
Expand Down Expand Up @@ -160,6 +162,9 @@ public function register(): void
$this->app->bind(PatreonServiceLoggingInterface::class, PatreonServiceLogging::class);
$this->app->bind(PatreonApiServiceLoggingInterface::class, PatreonApiServiceLogging::class);

// RaiderIO
$this->app->bind(RaiderIOApiServiceLoggingInterface::class, RaiderIOApiServiceLogging::class);

// Spell
$this->app->bind(SpellServiceLoggingInterface::class, SpellServiceLogging::class);

Expand Down
4 changes: 2 additions & 2 deletions app/Service/RaiderIO/Dtos/HeatmapDataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public function toArray(): array
{
$result = [
'challenge_mode_id' => $this->dungeon->challenge_mode_id,
'event_type' => $this->getEventType(),
'data_type' => $this->getDataType(),
'event_type' => $this->getEventType()->value,
'data_type' => $this->getDataType()->value,
];

if ($this->getLevelMin() !== null) {
Expand Down
24 changes: 24 additions & 0 deletions app/Service/RaiderIO/Logging/RaiderIOApiServiceLogging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Service\RaiderIO\Logging;

use App\Logging\RollbarStructuredLogging;

class RaiderIOApiServiceLogging extends RollbarStructuredLogging implements RaiderIOApiServiceLoggingInterface
{
public function getHeatmapDataStart(string $url): void
{
$this->start(__METHOD__, get_defined_vars());
}

public function getHeatmapDataResponse(string $response): void
{
$this->debug(__METHOD__, get_defined_vars());
}

public function getHeatmapDataEnd(): void
{
$this->end(__METHOD__);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Service\RaiderIO\Logging;

interface RaiderIOApiServiceLoggingInterface
{
public function getHeatmapDataStart(string $url): void;

public function getHeatmapDataResponse(string $response): void;

public function getHeatmapDataEnd(): void;
}
44 changes: 35 additions & 9 deletions app/Service/RaiderIO/RaiderIOApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,53 @@

use App\Service\RaiderIO\Dtos\HeatmapDataFilter;
use App\Service\RaiderIO\Dtos\HeatmapDataResponse\HeatmapDataResponse;
use App\Service\RaiderIO\Logging\RaiderIOApiServiceLoggingInterface;
use App\Service\Traits\Curl;
use Exception;
use Str;

class RaiderIOApiService implements RaiderIOApiServiceInterface
{
use Curl;

public function __construct(
private readonly RaiderIOApiServiceLoggingInterface $log
) {
}

public function getHeatmapData(HeatmapDataFilter $heatmapDataFilter): HeatmapDataResponse
{
// @TODO This endpoint does not exist, it's just a dummy for now
$url = 'https://raider.io/api/v1/keystoneguru/heatmap/data?region=eu&locale=en';
$response = $this->curlPost($url, $heatmapDataFilter->toArray());
$parameters = [];
foreach ($heatmapDataFilter->toArray() as $key => $value) {
$key = match ($key) {
'event_type' => 'type',
default => $key
};
$parameters[] = sprintf('%s=%s', Str::camel($key), $value);
}
$url = sprintf(
'%s?%s',
'https://raider.io/api/v1/live-tracking/heatmaps/grid',
implode('&', $parameters)
);

$json = json_decode($response, true);
try {
$this->log->getHeatmapDataStart($url);

if (!is_array($json)) {
// @TODO Add structured logging
throw new Exception(sprintf('Invalid response from RaiderIO API %s', $response));
}
$response = $this->curlGet($url);

return HeatmapDataResponse::fromArray($json);
$this->log->getHeatmapDataResponse($response);

$json = json_decode($response, true);

if (!is_array($json)) {
throw new Exception(sprintf('Invalid response from RaiderIO API %s', $response));
}

return HeatmapDataResponse::fromArray($json);
} finally {
$this->log->getHeatmapDataEnd();
}
}

}
2 changes: 1 addition & 1 deletion resources/views/common/dungeon/gridtabs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class="tab-pane fade show {{ $selectedSeasonId === null && $index === 0 ? 'activ

@if($expansion->hasRaidForGameVersion($currentUserGameVersion))
<div id="{{ $expansion->shortname }}-raid-grid-content"
class="tab-pane fade {{ $selectedSeasonId === null && $index === 0 ? 'active' : '' }}"
class="tab-pane fade show {{ $selectedSeasonId === null && $index === 0 ? 'active' : '' }}"
role="tabpanel"
aria-labelledby="{{ $expansion->shortname }}-raid-grid-content">
@php($raids = $expansion->raids()->active()->get())
Expand Down

0 comments on commit 6a2d3d1

Please sign in to comment.