Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/Controller/PanelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function beforeRender(EventInterface $event): void
*/
public function index(?string $requestId = null): void
{
$query = $this->Panels->find('byRequest', ['requestId' => $requestId]);
$query = $this->Panels->find('byRequest', requestId: $requestId);
$panels = $query->toArray();
if (empty($panels)) {
throw new NotFoundException();
Expand Down Expand Up @@ -107,7 +107,7 @@ public function latestHistory(): ?Response
throw new NotFoundException('No requests found');
}
/** @var array{id:string}|null $historyPanel */
$historyPanel = $this->Panels->find('byRequest', ['requestId' => $request['id']])
$historyPanel = $this->Panels->find('byRequest', requestId: $request['id'])
->where(['title' => 'History'])
->select(['id'])
->first();
Expand Down
14 changes: 4 additions & 10 deletions src/Model/Table/PanelsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Cake\ORM\Query\SelectQuery;
use Cake\ORM\Table;
use RuntimeException;

/**
* The panels table collects the information for each panel on
Expand Down Expand Up @@ -49,20 +48,15 @@ public function initialize(array $config): void
}

/**
* Find panels by requestid
* Find panels by request id
*
* @param \Cake\ORM\Query\SelectQuery $query The query
* @param array $options The options to use.
* @param string|int $requestId The request id
* @return \Cake\ORM\Query\SelectQuery The query.
* @throws \RuntimeException
*/
public function findByRequest(SelectQuery $query, array $options): SelectQuery
public function findByRequest(SelectQuery $query, string|int $requestId): SelectQuery
{
if (empty($options['requestId'])) {
throw new RuntimeException('Missing request id in findByRequest().');
}

return $query->where(['Panels.request_id' => $options['requestId']])
return $query->where(['Panels.request_id' => $requestId])
->orderBy(['Panels.title' => 'ASC']);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Model/Table/RequestsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ public static function defaultConnectionName(): string
* Finder method to get recent requests as a simple array
*
* @param \Cake\ORM\Query\SelectQuery $query The query
* @param array $options The options
* @return \Cake\ORM\Query\SelectQuery The query.
*/
public function findRecent(SelectQuery $query, array $options): SelectQuery
public function findRecent(SelectQuery $query): SelectQuery
{
return $query->orderBy(['Requests.requested_at' => 'DESC'])
->limit(10);
Expand Down