Skip to content

Commit 0d93d7f

Browse files
committed
apply suggestion from review
1 parent e48435f commit 0d93d7f

4 files changed

Lines changed: 6 additions & 20 deletions

File tree

app/Http/Resources/PublicWikiResource.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ public function toArray($request): array {
1616
'sitename' => $this->sitename,
1717
'wiki_site_stats' => $this->wikiSiteStats,
1818
'logo_url' => $logoSetting ? $logoSetting->value : null,
19-
20-
// Checking relation load state before reading it to avoid N+1 query
21-
// This relies on the controller to eager load `wikiLatestProfile` relationship
2219
'reuse_prototype' => $this->wikiLatestProfile
2320
? $this->wikiLatestProfile->purpose === 'data_hub'
2421
&& $this->wikiLatestProfile->temporality === 'permanent'
2522
&& $this->wikiLatestProfile->audience === 'wide'
26-
: null,
23+
: false,
2724
];
2825
}
2926
}

app/Providers/AppServiceProvider.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,5 @@ public function boot(): void {
2626
$wrappedException = new \Exception("Executing Job '$name' failed.", 1, $event->exception);
2727
report($wrappedException);
2828
});
29-
30-
// Local-only SQL query logging for debugging
31-
if ($this->app->environment('local')) {
32-
\Event::listen(QueryExecuted::class, function (QueryExecuted $query) {
33-
\Log::debug('Query Executed: ', [
34-
'sql' => $query->sql,
35-
'bindings' => $query->bindings,
36-
'connection' => $query->connectionName,
37-
]);
38-
});
39-
}
4029
}
4130
}

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
});
5858

5959
$router->apiResource('wiki', 'PublicWikiController')->only(['index', 'show']);
60-
$router->apiResource('reusePrototype', 'PublicWikiController')->only(['index', 'show']);
60+
$router->apiResource('reusePrototype', 'PublicWikiController')->only(['index']);
6161
$router->apiResource('wikiConversionData', 'ConversionMetricController')->only(['index']);
6262
});

tests/Http/Controllers/PublicWikiControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ public function testIndexEagerLoadsWikiLatestProfileOnceForCollection(): void {
5050
]);
5151
}
5252

53-
$profileQueryCount = 0;
54-
DB::listen(function (QueryExecuted $query) use (&$profileQueryCount): void {
53+
$wikiProfileQueryCount = 0;
54+
DB::listen(function (QueryExecuted $query) use (&$wikiProfileQueryCount): void {
5555
if (str_contains($query->sql, 'wiki_profiles')) {
56-
$profileQueryCount++;
56+
$wikiProfileQueryCount++;
5757
}
5858
});
5959

6060
$controller = new PublicWikiController;
6161
$resourceCollection = $controller->index(new Request);
6262

63-
$this->assertSame(1, $profileQueryCount);
63+
$this->assertSame(1, $wikiProfileQueryCount);
6464
$this->assertTrue($resourceCollection->first()->relationLoaded('wikiLatestProfile'));
6565
}
6666
}

0 commit comments

Comments
 (0)