@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add an "Activated Epoch" and an "Acquired Epoch" to Drydock Leases

Summary: Ref T13189. See PHI690. When a lease is first acquired or activated, note the time. This supports better visibility into queue lengths. For now, this is only queryable via DB and visible in the UI, but can be more broadly exposed in the future.

Test Plan: Landed a revision, saw the leases get sensible timestamps for acquisition/activation.

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13189

Differential Revision: https://secure.phabricator.com/D19613

+48
+2
resources/sql/autopatches/20180827.drydock.01.acquired.sql
··· 1 + ALTER TABLE {$NAMESPACE}_drydock.drydock_lease 2 + ADD acquiredEpoch INT UNSIGNED;
+2
resources/sql/autopatches/20180827.drydock.02.activated.sql
··· 1 + ALTER TABLE {$NAMESPACE}_drydock.drydock_lease 2 + ADD activatedEpoch INT UNSIGNED;
+24
src/applications/drydock/controller/DrydockLeaseViewController.php
··· 163 163 } 164 164 $view->addProperty(pht('Expires'), $until_display); 165 165 166 + $acquired_epoch = $lease->getAcquiredEpoch(); 167 + $activated_epoch = $lease->getActivatedEpoch(); 168 + 169 + if ($acquired_epoch) { 170 + $acquired_display = phabricator_datetime($acquired_epoch, $viewer); 171 + } else { 172 + if ($activated_epoch) { 173 + $acquired_display = phutil_tag( 174 + 'em', 175 + array(), 176 + pht('Activated on Acquisition')); 177 + } else { 178 + $acquired_display = phutil_tag('em', array(), pht('Not Acquired')); 179 + } 180 + } 181 + $view->addProperty(pht('Acquired'), $acquired_display); 182 + 183 + if ($activated_epoch) { 184 + $activated_display = phabricator_datetime($activated_epoch, $viewer); 185 + } else { 186 + $activated_display = phutil_tag('em', array(), pht('Not Activated')); 187 + } 188 + $view->addProperty(pht('Activated'), $activated_display); 189 + 166 190 $attributes = $lease->getAttributes(); 167 191 if ($attributes) { 168 192 $view->addSectionHeader(
+20
src/applications/drydock/storage/DrydockLease.php
··· 10 10 protected $authorizingPHID; 11 11 protected $attributes = array(); 12 12 protected $status = DrydockLeaseStatus::STATUS_PENDING; 13 + protected $acquiredEpoch; 14 + protected $activatedEpoch; 13 15 14 16 private $resource = self::ATTACHABLE; 15 17 private $unconsumedCommands = self::ATTACHABLE; ··· 62 64 $this->scheduleUpdate(); 63 65 } 64 66 67 + public function setStatus($status) { 68 + if ($status == DrydockLeaseStatus::STATUS_ACQUIRED) { 69 + if (!$this->getAcquiredEpoch()) { 70 + $this->setAcquiredEpoch(PhabricatorTime::getNow()); 71 + } 72 + } 73 + 74 + if ($status == DrydockLeaseStatus::STATUS_ACTIVE) { 75 + if (!$this->getActivatedEpoch()) { 76 + $this->setActivatedEpoch(PhabricatorTime::getNow()); 77 + } 78 + } 79 + 80 + return parent::setStatus($status); 81 + } 82 + 65 83 public function getLeaseName() { 66 84 return pht('Lease %d', $this->getID()); 67 85 } ··· 78 96 'resourceType' => 'text128', 79 97 'ownerPHID' => 'phid?', 80 98 'resourcePHID' => 'phid?', 99 + 'acquiredEpoch' => 'epoch?', 100 + 'activatedEpoch' => 'epoch?', 81 101 ), 82 102 self::CONFIG_KEY_SCHEMA => array( 83 103 'key_resource' => array(