Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/storage/DrydockLease.php
Show First 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | public function canRelease() { | ||||
switch ($this->getStatus()) { | switch ($this->getStatus()) { | ||||
case DrydockLeaseStatus::STATUS_RELEASED: | case DrydockLeaseStatus::STATUS_RELEASED: | ||||
return false; | return false; | ||||
default: | default: | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
public function scheduleUpdate() { | public function scheduleUpdate($epoch = null) { | ||||
PhabricatorWorker::scheduleTask( | PhabricatorWorker::scheduleTask( | ||||
'DrydockLeaseUpdateWorker', | 'DrydockLeaseUpdateWorker', | ||||
array( | array( | ||||
'leasePHID' => $this->getPHID(), | 'leasePHID' => $this->getPHID(), | ||||
'isExpireTask' => ($epoch !== null), | |||||
), | ), | ||||
array( | array( | ||||
'objectPHID' => $this->getPHID(), | 'objectPHID' => $this->getPHID(), | ||||
'delayUntil' => $epoch, | |||||
)); | )); | ||||
} | } | ||||
private function didActivate() { | private function didActivate() { | ||||
$viewer = PhabricatorUser::getOmnipotentUser(); | $viewer = PhabricatorUser::getOmnipotentUser(); | ||||
$need_update = false; | $need_update = false; | ||||
$commands = id(new DrydockCommandQuery()) | $commands = id(new DrydockCommandQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withTargetPHIDs(array($this->getPHID())) | ->withTargetPHIDs(array($this->getPHID())) | ||||
->withConsumed(false) | ->withConsumed(false) | ||||
->execute(); | ->execute(); | ||||
if ($commands) { | if ($commands) { | ||||
$need_update = true; | $need_update = true; | ||||
} | } | ||||
if ($need_update) { | if ($need_update) { | ||||
$this->scheduleUpdate(); | $this->scheduleUpdate(); | ||||
} | } | ||||
$expires = $this->getUntil(); | |||||
if ($expires) { | |||||
$this->scheduleUpdate($expires); | |||||
} | |||||
} | } | ||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
Show All 27 Lines |