@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Home - limit "status" queries to 100 and show 99+ if we hit that

Summary: Fixes T6595. This diff has two issues as is... 1) the differential data fetching is pretty cheesey, but it looks like we can't just issue three separate databases to get the right data? 2) the translations break, since I am turning this into a string (and not an int) so the whole pluralization bit fails. I think 1 is okay as is and 2 needs to be fixed though I am not sure how to best do that...

Test Plan: loaded home page and it looked nice...!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6595

Differential Revision: https://secure.phabricator.com/D10979

+126 -38
+14 -4
src/applications/audit/application/PhabricatorAuditApplication.php
··· 54 54 $query = id(new DiffusionCommitQuery()) 55 55 ->setViewer($user) 56 56 ->withAuthorPHIDs(array($user->getPHID())) 57 - ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN); 57 + ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN) 58 + ->setLimit(self::MAX_STATUS_ITEMS); 58 59 $commits = $query->execute(); 59 60 60 61 $count = count($commits); 62 + $count_str = self::formatStatusCount( 63 + $count, 64 + '%s Problem Commits', 65 + '%d Problem Commit(s)'); 61 66 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 62 67 $status[] = id(new PhabricatorApplicationStatusView()) 63 68 ->setType($type) 64 - ->setText(pht('%d Problem Commit(s)', $count)) 69 + ->setText($count_str) 65 70 ->setCount($count); 66 71 67 72 $query = id(new DiffusionCommitQuery()) 68 73 ->setViewer($user) 69 74 ->withAuditorPHIDs($phids) 70 75 ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_OPEN) 71 - ->withAuditAwaitingUser($user); 76 + ->withAuditAwaitingUser($user) 77 + ->setLimit(self::MAX_STATUS_ITEMS); 72 78 $commits = $query->execute(); 73 79 74 80 $count = count($commits); 81 + $count_str = self::formatStatusCount( 82 + $count, 83 + '%s Commits Awaiting Audit', 84 + '%d Commit(s) Awaiting Audit'); 75 85 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 76 86 $status[] = id(new PhabricatorApplicationStatusView()) 77 87 ->setType($type) 78 - ->setText(pht('%d Commit(s) Awaiting Audit', $count)) 88 + ->setText($count_str) 79 89 ->setCount($count); 80 90 81 91 return $status;
+18
src/applications/base/PhabricatorApplication.php
··· 9 9 */ 10 10 abstract class PhabricatorApplication implements PhabricatorPolicyInterface { 11 11 12 + const MAX_STATUS_ITEMS = 100; 13 + 12 14 const GROUP_CORE = 'core'; 13 15 const GROUP_UTILITIES = 'util'; 14 16 const GROUP_ADMIN = 'admin'; ··· 229 231 */ 230 232 public function loadStatus(PhabricatorUser $user) { 231 233 return array(); 234 + } 235 + 236 + /** 237 + * @return string 238 + * @task ui 239 + */ 240 + public static function formatStatusCount( 241 + $count, 242 + $limit_string = '%s', 243 + $base_string = '%d') { 244 + if ($count == self::MAX_STATUS_ITEMS) { 245 + $count_str = pht($limit_string, ($count - 1).'+'); 246 + } else { 247 + $count_str = pht($base_string, $count); 248 + } 249 + return $count_str; 232 250 } 233 251 234 252
+48 -23
src/applications/differential/application/PhabricatorDifferentialApplication.php
··· 100 100 ->withResponsibleUsers(array($user->getPHID())) 101 101 ->withStatus(DifferentialRevisionQuery::STATUS_OPEN) 102 102 ->needRelationships(true) 103 + ->setLimit(self::MAX_STATUS_ITEMS) 103 104 ->execute(); 104 105 105 - list($blocking, $active, $waiting) = 106 - DifferentialRevisionQuery::splitResponsible( 107 - $revisions, 108 - array($user->getPHID())); 109 - 110 106 $status = array(); 107 + if (count($revisions) == self::MAX_STATUS_ITEMS) { 108 + $all_count = count($revisions); 109 + $all_count_str = self::formatStatusCount( 110 + $all_count, 111 + '%s Active Reviews', 112 + '%d Active Review(s)'); 113 + $type = PhabricatorApplicationStatusView::TYPE_WARNING; 114 + $status[] = id(new PhabricatorApplicationStatusView()) 115 + ->setType($type) 116 + ->setText($all_count_str) 117 + ->setCount($all_count); 118 + } else { 119 + list($blocking, $active, $waiting) = 120 + DifferentialRevisionQuery::splitResponsible( 121 + $revisions, 122 + array($user->getPHID())); 111 123 112 - $blocking = count($blocking); 113 - $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 114 - $status[] = id(new PhabricatorApplicationStatusView()) 115 - ->setType($type) 116 - ->setText(pht('%d Review(s) Blocking Others', $blocking)) 117 - ->setCount($blocking); 124 + $blocking = count($blocking); 125 + $blocking_str = self::formatStatusCount( 126 + $blocking, 127 + '%s Reviews Blocking Others', 128 + '%d Review(s) Blocking Others'); 129 + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 130 + $status[] = id(new PhabricatorApplicationStatusView()) 131 + ->setType($type) 132 + ->setText($blocking_str) 133 + ->setCount($blocking); 118 134 119 - $active = count($active); 120 - $type = PhabricatorApplicationStatusView::TYPE_WARNING; 121 - $status[] = id(new PhabricatorApplicationStatusView()) 122 - ->setType($type) 123 - ->setText(pht('%d Review(s) Need Attention', $active)) 124 - ->setCount($active); 135 + $active = count($active); 136 + $active_str = self::formatStatusCount( 137 + $active, 138 + '%s Reviews Need Attention', 139 + '%d Review(s) Need Attention'); 140 + $type = PhabricatorApplicationStatusView::TYPE_WARNING; 141 + $status[] = id(new PhabricatorApplicationStatusView()) 142 + ->setType($type) 143 + ->setText($active_str) 144 + ->setCount($active); 125 145 126 - $waiting = count($waiting); 127 - $type = PhabricatorApplicationStatusView::TYPE_INFO; 128 - $status[] = id(new PhabricatorApplicationStatusView()) 129 - ->setType($type) 130 - ->setText(pht('%d Review(s) Waiting on Others', $waiting)) 131 - ->setCount($waiting); 146 + $waiting = count($waiting); 147 + $waiting_str = self::formatStatusCount( 148 + $waiting, 149 + '%s Reviews Waiting on Others', 150 + '%d Review(s) Waiting on Others'); 151 + $type = PhabricatorApplicationStatusView::TYPE_INFO; 152 + $status[] = id(new PhabricatorApplicationStatusView()) 153 + ->setType($type) 154 + ->setText($waiting_str) 155 + ->setCount($waiting); 156 + } 132 157 133 158 return $status; 134 159 }
+6 -1
src/applications/flag/application/PhabricatorFlagsApplication.php
··· 38 38 $flags = id(new PhabricatorFlagQuery()) 39 39 ->setViewer($user) 40 40 ->withOwnerPHIDs(array($user->getPHID())) 41 + ->setLimit(self::MAX_STATUS_ITEMS) 41 42 ->execute(); 42 43 43 44 $count = count($flags); 45 + $count_str = self::formatStatusCount( 46 + $count, 47 + '%s Flagged Objects', 48 + '%d Flagged Object(s)'); 44 49 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 45 50 $status[] = id(new PhabricatorApplicationStatusView()) 46 51 ->setType($type) 47 - ->setText(pht('%d Flagged Object(s)', $count)) 52 + ->setText($count_str) 48 53 ->setCount($count); 49 54 50 55 return $status;
+7 -2
src/applications/maniphest/application/PhabricatorManiphestApplication.php
··· 80 80 $query = id(new ManiphestTaskQuery()) 81 81 ->setViewer($user) 82 82 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 83 - ->withOwners(array($user->getPHID())); 83 + ->withOwners(array($user->getPHID())) 84 + ->setLimit(self::MAX_STATUS_ITEMS); 84 85 $count = count($query->execute()); 86 + $count_str = self::formatStatusCount( 87 + $count, 88 + '%s Assigned Tasks', 89 + '%d Assigned Task(s)'); 85 90 86 91 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 87 92 $status[] = id(new PhabricatorApplicationStatusView()) 88 93 ->setType($type) 89 - ->setText(pht('%s Assigned Task(s)', new PhutilNumber($count))) 94 + ->setText($count_str) 90 95 ->setCount($count); 91 96 92 97 return $status;
+2 -2
src/applications/meta/view/PhabricatorApplicationLaunchView.php
··· 73 73 array( 74 74 'class' => 'phabricator-application-attention-count', 75 75 ), 76 - $count); 76 + PhabricatorApplication::formatStatusCount($count)); 77 77 } 78 78 79 79 ··· 83 83 array( 84 84 'class' => 'phabricator-application-warning-count', 85 85 ), 86 - $counts[$warning]); 86 + PhabricatorApplication::formatStatusCount($counts[$warning])); 87 87 } 88 88 if (nonempty($count1) && nonempty($count2)) { 89 89 $numbers = array($count1, ' / ', $count2);
+6 -1
src/applications/people/application/PhabricatorPeopleApplication.php
··· 91 91 ->setViewer($user) 92 92 ->withIsApproved(false) 93 93 ->withIsDisabled(false) 94 + ->setLimit(self::MAX_STATUS_ITEMS) 94 95 ->execute(); 95 96 96 97 if (!$need_approval) { ··· 100 101 $status = array(); 101 102 102 103 $count = count($need_approval); 104 + $count_str = self::formatStatusCount( 105 + $count, 106 + '%s Users Need Approval', 107 + '%d User(s) Need Approval'); 103 108 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 104 109 $status[] = id(new PhabricatorApplicationStatusView()) 105 110 ->setType($type) 106 - ->setText(pht('%d User(s) Need Approval', $count)) 111 + ->setText($count_str) 107 112 ->setCount($count); 108 113 109 114 return $status;
+8 -2
src/applications/phrequent/application/PhabricatorPhrequentApplication.php
··· 52 52 // Show number of objects that are currently 53 53 // being tracked for a user. 54 54 55 - $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked($user); 55 + $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked( 56 + $user, 57 + self::MAX_STATUS_ITEMS); 58 + $count_str = self::formatStatusCount( 59 + $count, 60 + '%s Objects Tracked', 61 + '%d Object(s) Tracked'); 56 62 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 57 63 $status[] = id(new PhabricatorApplicationStatusView()) 58 64 ->setType($type) 59 - ->setText(pht('%d Object(s) Tracked', $count)) 65 + ->setText($count_str) 60 66 ->setCount($count); 61 67 62 68 return $status;
+6 -3
src/applications/phrequent/query/PhrequentUserTimeQuery.php
··· 255 255 } 256 256 257 257 public static function getUserTotalObjectsTracked( 258 - PhabricatorUser $user) { 258 + PhabricatorUser $user, 259 + $limit = PHP_INT_MAX) { 259 260 260 261 $usertime_dao = new PhrequentUserTime(); 261 262 $conn = $usertime_dao->establishConnection('r'); ··· 264 265 $conn, 265 266 'SELECT COUNT(usertime.id) N FROM %T usertime '. 266 267 'WHERE usertime.userPHID = %s '. 267 - 'AND usertime.dateEnded IS NULL', 268 + 'AND usertime.dateEnded IS NULL '. 269 + 'LIMIT %d', 268 270 $usertime_dao->getTableName(), 269 - $user->getPHID()); 271 + $user->getPHID(), 272 + $limit); 270 273 return $count['N']; 271 274 } 272 275
+1
src/applications/ponder/application/PhabricatorPonderApplication.php
··· 30 30 31 31 public function loadStatus(PhabricatorUser $user) { 32 32 // replace with "x new unanswered questions" or some such 33 + // make sure to use self::formatStatusCount and friends...! 33 34 $status = array(); 34 35 35 36 return $status;
+10
src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php
··· 172 172 '%d Reviews Waiting on Others', 173 173 ), 174 174 175 + '%d Active Review(s)' => array( 176 + '%d Active Review', 177 + '%d Active Reviews', 178 + ), 179 + 175 180 '%d Flagged Object(s)' => array( 176 181 '%d Flagged Object', 177 182 '%d Flagged Objects', 183 + ), 184 + 185 + '%d Object(s) Tracked' => array( 186 + '%d Object Tracked', 187 + '%d Objects Tracked', 178 188 ), 179 189 180 190 '%d Unbreak Now Task(s)!' => array(