Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/PublicWikiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function index(Request $request) {
]);

$params = array_merge(self::$defaultParams, $request->input());
$query = Wiki::query();
$query = Wiki::query()->with('wikiLatestProfile');

if (array_key_exists('is_featured', $params)) {
$query = $query->where([
Expand Down
15 changes: 15 additions & 0 deletions app/Http/Resources/PublicWikiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ public function toArray($request): array {
'sitename' => $this->sitename,
'wiki_site_stats' => $this->wikiSiteStats,
'logo_url' => $logoSetting ? $logoSetting->value : null,

// TODO: delete these three fields before merging; here to easily prove the `reuse_prototype` logic works
'test_purpose' => $this->wikiLatestProfile ? $this->wikiLatestProfile->purpose : null,
'test_temporality' => $this->wikiLatestProfile ? $this->wikiLatestProfile->temporality : null,
'test_audience' => $this->wikiLatestProfile ? $this->wikiLatestProfile->audience : null,

// TODO: As the `$this->wikiLatestProfile` property can be accessed regardless of if
// `->with('wikiLatestProfile')` is used in the controller, we are unable to return null if
// `$this->wikiLatestProfile` isn't set. We should either look into addressing this, or remove the
// `$this->wikiLatestProfile ? ... : null` conditional.
'reuse_prototype' => $this->wikiLatestProfile
? $this->wikiLatestProfile->purpose === 'data_hub'
&& $this->wikiLatestProfile->temporality === 'permanent'
&& $this->wikiLatestProfile->audience === 'wide'
: null,
];
}
}
12 changes: 12 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Curl\CurlRequest;
use App\Http\Curl\HttpRequest;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider;
Expand All @@ -25,5 +26,16 @@ public function boot(): void {
$wrappedException = new \Exception("Executing Job '$name' failed.", 1, $event->exception);
report($wrappedException);
});

// TODO: delete this listener before merging or is it useful to keep in the local environment?
if ($this->app->environment('local')) {
\Event::listen(QueryExecuted::class, function (QueryExecuted $query) {
\Log::debug('Query Executed: ', [
'sql' => $query->sql,
'bindings' => $query->bindings,
'connection' => $query->connectionName,
]);
});
}
}
}
Loading