3 final class PhrequentTrackingEditor
extends PhabricatorEditor
{
5 public function startTracking(PhabricatorUser
$user, $phid, $timestamp) {
6 $usertime = new PhrequentUserTime();
7 $usertime->setDateStarted($timestamp);
8 $usertime->setUserPHID($user->getPHID());
9 $usertime->setObjectPHID($phid);
15 public function stopTracking(
16 PhabricatorUser
$user,
21 if (!PhrequentUserTimeQuery
::isUserTrackingObject($user, $phid)) {
22 // Don't do anything, it's not being tracked.
26 $usertime_dao = new PhrequentUserTime();
27 $conn = $usertime_dao->establishConnection('r');
31 'UPDATE %T usertime '.
32 'SET usertime.dateEnded = %d, '.
33 'usertime.note = %s '.
34 'WHERE usertime.userPHID = %s '.
35 'AND usertime.objectPHID = %s '.
36 'AND usertime.dateEnded IS NULL '.
37 'ORDER BY usertime.dateStarted, usertime.id DESC '.
39 $usertime_dao->getTableName(),
48 public function stopTrackingTop(PhabricatorUser
$user, $timestamp, $note) {
49 $times = id(new PhrequentUserTimeQuery())
51 ->withUserPHIDs(array($user->getPHID()))
52 ->withEnded(PhrequentUserTimeQuery
::ENDED_NO
)
53 ->setOrder(PhrequentUserTimeQuery
::ORDER_STARTED_DESC
)
56 if (count($times) === 0) {
57 // Nothing to stop tracking.
61 $current = head($times);
63 return $this->stopTracking(
65 $current->getObjectPHID(),