@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.

Remove obsolete code from ManiphestTaskQuery

Summary:
Ref T603. Cleans up some obsolete stuff here:

- We no longer ever query by min/max priority (instead, `withPriorities(...)`).
- A parent class provides limit/offset.
- Result count is no longer reliable with policies. We could do "about X tasks" or something, but just drop it for now. There's only one remaining callsite anyway.

Test Plan:
- `grep`
- Viewed task list.
- Viewed a project page.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

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

+3 -81
+1 -75
src/applications/maniphest/query/ManiphestTaskQuery.php
··· 36 36 const STATUS_DUPLICATE = 'status-duplicate'; 37 37 38 38 private $statuses; 39 - 40 - private $priority = null; 41 39 private $priorities; 42 - 43 - private $minPriority = null; 44 - private $maxPriority = null; 45 40 46 41 private $groupBy = 'group-none'; 47 42 const GROUP_NONE = 'group-none'; ··· 56 51 const ORDER_MODIFIED = 'order-modified'; 57 52 const ORDER_TITLE = 'order-title'; 58 53 59 - private $limit = null; 60 54 const DEFAULT_PAGE_SIZE = 1000; 61 - 62 - private $offset = 0; 63 - private $calculateRows = false; 64 - 65 - private $rowCount = null; 66 55 67 56 public function withAuthors(array $authors) { 68 57 $this->authorPHIDs = $authors; ··· 119 108 return $this; 120 109 } 121 110 122 - public function withPriority($priority) { 123 - $this->priority = $priority; 124 - return $this; 125 - } 126 - 127 111 public function withPriorities(array $priorities) { 128 112 $this->priorities = $priorities; 129 113 return $this; 130 114 } 131 115 132 - public function withPrioritiesBetween($min, $max) { 133 - $this->minPriority = $min; 134 - $this->maxPriority = $max; 135 - return $this; 136 - } 137 - 138 116 public function withSubscribers(array $subscribers) { 139 117 $this->subscriberPHIDs = $subscribers; 140 118 return $this; ··· 155 133 return $this; 156 134 } 157 135 158 - public function setCalculateRows($calculate_rows) { 159 - $this->calculateRows = $calculate_rows; 160 - return $this; 161 - } 162 - 163 - public function getRowCount() { 164 - if ($this->rowCount === null) { 165 - throw new Exception( 166 - "You must execute a query with setCalculateRows() before you can ". 167 - "retrieve a row count."); 168 - } 169 - return $this->rowCount; 170 - } 171 - 172 136 public function withAnyProjects(array $projects) { 173 137 $this->anyProjectPHIDs = $projects; 174 138 return $this; ··· 200 164 $task_dao = new ManiphestTask(); 201 165 $conn = $task_dao->establishConnection('r'); 202 166 203 - if ($this->calculateRows) { 204 - $calc = 'SQL_CALC_FOUND_ROWS'; 205 - 206 - // Make sure we end up in the right state if we throw a 207 - // PhabricatorEmptyQueryException. 208 - $this->rowCount = 0; 209 - } else { 210 - $calc = ''; 211 - } 212 - 213 167 $where = array(); 214 168 $where[] = $this->buildTaskIDsWhereClause($conn); 215 169 $where[] = $this->buildTaskPHIDsWhereClause($conn); 216 170 $where[] = $this->buildStatusWhereClause($conn); 217 171 $where[] = $this->buildStatusesWhereClause($conn); 218 - $where[] = $this->buildPriorityWhereClause($conn); 219 172 $where[] = $this->buildPrioritiesWhereClause($conn); 220 173 $where[] = $this->buildAuthorWhereClause($conn); 221 174 $where[] = $this->buildOwnerWhereClause($conn); ··· 277 230 278 231 $rows = queryfx_all( 279 232 $conn, 280 - 'SELECT %Q task.* %Q %Q FROM %T task %Q %Q %Q %Q %Q %Q', 281 - $calc, 233 + 'SELECT task.* %Q %Q FROM %T task %Q %Q %Q %Q %Q %Q', 282 234 $count, 283 235 $group_column, 284 236 $task_dao->getTableName(), ··· 289 241 $order, 290 242 $this->buildLimitClause($conn)); 291 243 292 - if ($this->calculateRows) { 293 - $count = queryfx_one( 294 - $conn, 295 - 'SELECT FOUND_ROWS() N'); 296 - $this->rowCount = $count['N']; 297 - } else { 298 - $this->rowCount = null; 299 - } 300 - 301 244 switch ($this->groupBy) { 302 245 case self::GROUP_PROJECT: 303 246 $data = ipull($rows, null, 'id'); ··· 402 345 'status IN (%Ld)', 403 346 $this->statuses); 404 347 } 405 - return null; 406 - } 407 - 408 - private function buildPriorityWhereClause(AphrontDatabaseConnection $conn) { 409 - if ($this->priority !== null) { 410 - return qsprintf( 411 - $conn, 412 - 'priority = %d', 413 - $this->priority); 414 - } elseif ($this->minPriority !== null && $this->maxPriority !== null) { 415 - return qsprintf( 416 - $conn, 417 - 'priority >= %d AND priority <= %d', 418 - $this->minPriority, 419 - $this->maxPriority); 420 - } 421 - 422 348 return null; 423 349 } 424 350
+2 -6
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 158 158 ->withAnyProjects(array($project->getPHID())) 159 159 ->withStatus(ManiphestTaskQuery::STATUS_OPEN) 160 160 ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) 161 - ->setLimit(10) 162 - ->setCalculateRows(true); 161 + ->setLimit(10); 163 162 $tasks = $query->execute(); 164 - $count = $query->getRowCount(); 165 163 166 164 $phids = mpull($tasks, 'getOwnerPHID'); 167 165 $phids = array_merge( ··· 175 173 $task_list->setTasks($tasks); 176 174 $task_list->setHandles($handles); 177 175 178 - $open = number_format($count); 179 - 180 176 $content = hsprintf( 181 177 '<div class="phabricator-profile-info-group profile-wrap-responsive"> 182 178 <h1 class="phabricator-profile-info-header">%s</h1>'. ··· 184 180 '%s'. 185 181 '</div> 186 182 </div>', 187 - pht('Open Tasks (%s)', $open), 183 + pht('Open Tasks'), 188 184 $task_list); 189 185 190 186 return $content;