diff --git a/src/applications/phrequent/application/PhabricatorApplicationPhrequent.php b/src/applications/phrequent/application/PhabricatorApplicationPhrequent.php index 7ad72b664f..648c5dd1f5 100644 --- a/src/applications/phrequent/application/PhabricatorApplicationPhrequent.php +++ b/src/applications/phrequent/application/PhabricatorApplicationPhrequent.php @@ -45,27 +45,16 @@ final class PhabricatorApplicationPhrequent extends PhabricatorApplication { public function loadStatus(PhabricatorUser $user) { $status = array(); - // TODO: Show number of timers that are currently - // running for a user. + // Show number of objects that are currently + // being tracked for a user. - /* - - $query = id(new ManiphestTaskQuery()) - ->withStatus(ManiphestTaskQuery::STATUS_OPEN) - ->withOwners(array($user->getPHID())) - ->setLimit(1) - ->setCalculateRows(true); - $query->execute(); - - $count = $query->getRowCount(); - $type = PhabricatorApplicationStatusView::TYPE_WARNING; + $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked($user); + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) - ->setText(pht('%d Assigned Task(s)', $count)) + ->setText(pht('%d Object(s) Tracked', $count)) ->setCount($count); - */ - return $status; } diff --git a/src/applications/phrequent/query/PhrequentUserTimeQuery.php b/src/applications/phrequent/query/PhrequentUserTimeQuery.php index 967b7d94b2..b4660a60b6 100644 --- a/src/applications/phrequent/query/PhrequentUserTimeQuery.php +++ b/src/applications/phrequent/query/PhrequentUserTimeQuery.php @@ -79,6 +79,22 @@ final class PhrequentUserTimeQuery extends PhabricatorOffsetPagedQuery { /* -( Helper Functions ) --------------------------------------------------- */ + public static function getUserTotalObjectsTracked( + PhabricatorUser $user) { + + $usertime_dao = new PhrequentUserTime(); + $conn = $usertime_dao->establishConnection('r'); + + $count = queryfx_one( + $conn, + 'SELECT COUNT(usertime.id) N FROM %T usertime '. + 'WHERE usertime.userPHID = %s '. + 'AND usertime.dateEnded IS NULL', + $usertime_dao->getTableName(), + $user->getPHID()); + return $count['N']; + } + public static function isUserTrackingObject( PhabricatorUser $user, $phid) {