1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Fix two straggling pagination issues in Drydock

Summary:
Ref T13289. See <https://discourse.phabricator-community.org/t/fatal-error-in-pagination-in-drydock-resources-host-logs-all-logs/2735>.

`bin/drydock lease` and the web UI for reviewing all object logs when there is more than one page of logs didn't get fully updated to the new cursors.

  - Use a cursor pager in `bin/drydock lease`.
  - Implement `withIDs()` in `LeaseQuery` so the default paging works properly.

Test Plan:
  - Ran `bin/drydock lease`, got a lease with log output along the way.
  - Set page size to 2, viewed host logs with multiple pages, paged to page 2.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13289

Differential Revision: https://secure.phabricator.com/D20553
This commit is contained in:
epriestley 2019-05-23 11:52:43 -07:00
parent 2e2dc47f07
commit f838ad1827
2 changed files with 17 additions and 2 deletions

View file

@ -151,13 +151,15 @@ final class DrydockManagementLeaseWorkflow
while (!$is_active) { while (!$is_active) {
$lease->reload(); $lease->reload();
$pager = id(new AphrontCursorPagerView())
->setBeforeID($log_cursor);
// While we're waiting, show the user any logs which the daemons have // While we're waiting, show the user any logs which the daemons have
// generated to give them some clue about what's going on. // generated to give them some clue about what's going on.
$logs = id(new DrydockLogQuery()) $logs = id(new DrydockLogQuery())
->setViewer($viewer) ->setViewer($viewer)
->withLeasePHIDs(array($lease->getPHID())) ->withLeasePHIDs(array($lease->getPHID()))
->setBeforeID($log_cursor) ->executeWithCursorPager($pager);
->execute();
if ($logs) { if ($logs) {
$logs = mpull($logs, null, 'getID'); $logs = mpull($logs, null, 'getID');
ksort($logs); ksort($logs);

View file

@ -2,11 +2,17 @@
final class DrydockLogQuery extends DrydockQuery { final class DrydockLogQuery extends DrydockQuery {
private $ids;
private $blueprintPHIDs; private $blueprintPHIDs;
private $resourcePHIDs; private $resourcePHIDs;
private $leasePHIDs; private $leasePHIDs;
private $operationPHIDs; private $operationPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withBlueprintPHIDs(array $phids) { public function withBlueprintPHIDs(array $phids) {
$this->blueprintPHIDs = $phids; $this->blueprintPHIDs = $phids;
return $this; return $this;
@ -126,6 +132,13 @@ final class DrydockLogQuery extends DrydockQuery {
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn); $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ls)',
$this->ids);
}
if ($this->blueprintPHIDs !== null) { if ($this->blueprintPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,