From c3c88fd40cf49d62894799f6c489dcb7df76996e Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Sat, 30 Mar 2013 09:34:00 -0700 Subject: [PATCH] Implemented showing the number of objects tracked as application status. Summary: Implementing that TODO where we want to show the current number of objects being tracked by a user on the application icon so that they're aware of any timers that are running. Depends on D5479 Test Plan: Apply this patch and track a Maniphest task. The counter should show the number of objects you are tracking in the navigation pane of the main screen Reviewers: epriestley CC: aran, Korvin Maniphest Tasks: T2857 Differential Revision: https://secure.phabricator.com/D5480 --- .../PhabricatorApplicationPhrequent.php | 21 +++++-------------- .../query/PhrequentUserTimeQuery.php | 16 ++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) 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) {