1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

Add a call to predict the next event for a trigger

Summary: Ref T6881. This is useful to show a "Next backup: 2:30 AM" sort of thing without requring callers to know how triggers work internally.

Test Plan: Showed that kind of thing in Instances.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6881

Differential Revision: https://secure.phabricator.com/D11437
This commit is contained in:
epriestley 2015-01-19 16:56:03 -08:00
parent ef106d2979
commit 02eca684ae

View file

@ -130,6 +130,26 @@ final class PhabricatorWorkerTrigger
}
/**
* Predict the epoch at which this trigger will next fire.
*
* @return int|null Epoch when the event will next fire, or `null` if it is
* not planned to trigger.
*/
public function getNextEventPrediction() {
// NOTE: We're basically echoing the database state here, so this won't
// necessarily be accurate if the caller just updated the object but has
// not saved it yet. That's a weird use case and would require more
// gymnastics, so don't bother trying to get it totally correct for now.
if ($this->getEvent()) {
return $this->getEvent()->getNextEpoch();
} else {
return $this->getNextEventEpoch(null, $is_reschedule = false);
}
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */