r61830 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61829‎ | r61830 | r61831 >
Date:22:59, 1 February 2010
Author:pdhanda
Status:resolved (Comments)
Tags:
Comment:
Some cleanup after catrope's feedback
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionAuthorView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionStatusView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -77,6 +77,7 @@
7878 'code-rev-diff-link' => 'diff',
7979 'code-rev-diff-too-large' => 'The diff is too large to display.',
8080 'code-rev-purge-link' => 'purge',
 81+ 'code-rev-total' => 'Total number of results: ',
8182 'code-status-new' => 'new',
8283 'code-status-fixme' => 'fixme',
8384 'code-status-reverted' => 'reverted',
Index: trunk/extensions/CodeReview/ui/CodeRevisionAuthorView.php
@@ -44,8 +44,8 @@
4545 parent::execute();
4646 }
4747
48 - function getSpecializedWhereClause($dbr) {
49 - return ' AND cr_author = ' . $dbr->addQuotes($this->mAuthor);
 48+ function getSpecializedWhereClause( $dbr ) {
 49+ return ' AND cr_author = ' . $dbr->addQuotes( $this->mAuthor );
5050 }
5151
5252 }
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -28,16 +28,15 @@
2929 $this->doBatchChange();
3030 return;
3131 }
32 -
 32+
3333 $this->showForm();
3434
3535 //get the total count across all pages
36 - $dbr =& wfGetDB(DB_SLAVE);
37 - $revCountRes = $this->getRevCountQuery($dbr);
 36+ $dbr =& wfGetDB( DB_SLAVE );
 37+ $revCountRes = $this->getRevCountQuery( $dbr );
3838 $revCount = 0;
39 - if ($dbr->numRows($revCountRes) > 0){
40 - $row = $dbr->fetchObject($revCountRes);
41 - $revCount = $row->rev_count;
 39+ if ( $revCountRes !== false ) {
 40+ $revCount = $revCountRes->rev_count;
4241 }
4342
4443 $pager = $this->getPager();
@@ -51,7 +50,7 @@
5251 $pager->getNavigationBar() .
5352 $pager->getLimitForm() .
5453 '</td><td style="padding-left: 2em;">' .
55 - '&nbsp;Total number of results: <span style="font-weight: bold;">' . $revCount . '</span>' .
 54+ '&nbsp;' . wfMsgHtml( 'code-rev-total' ) . '<span style="font-weight: bold;">' . $revCount . '</span>' .
5655 '</td></tr></table>' .
5756 Xml::openElement( 'form',
5857 array( 'action' => $pager->getTitle()->getLocalURL(), 'method' => 'post' )
@@ -161,29 +160,28 @@
162161 return new SvnRevTablePager( $this );
163162 }
164163
165 - function getRevCountQuery($dbr) {
166 - $sql = 'SELECT COUNT(cr_id) AS rev_count' .
167 - ' FROM ' . $dbr->tableName('code_rev') . ' ';
 164+ function getRevCountQuery( $dbr ) {
 165+ $tables = array( $dbr->tableName( 'code_rev' ) );
 166+ $selectFields = array( 'COUNT( cr_id ) AS rev_count' );
168167 // count if code_rev where path matches
169168 if ( $this->mPath ) {
170 - $sql .= ' WHERE cr_id in' .
171 - ' (SELECT cp_rev_id from code_paths' .
172 - ' WHERE' .
 169+ $whereCond = 'cr_id IN' .
 170+ ' ( SELECT cp_rev_id FROM '. $dbr->tableName( 'code_paths' ) . ' WHERE' .
173171 ' cp_repo_id = ' . $this->mRepo->getId(). ' AND' .
174 - ' cp_path LIKE ' . $dbr->addQuotes( $this->mPath . '%') . ' AND' .
 172+ ' cp_path LIKE ' . $dbr->addQuotes( $this->mPath . '%' ) . ' AND' .
175173 // performance
176 - ' cp_rev_id > ' . ($this->mRepo->getLastStoredRev() - 20000) .
177 - $this->getSpecializedWhereClause($dbr) .
178 - ')';
 174+ ' cp_rev_id > ' . ( $this->mRepo->getLastStoredRev() - 20000 ) .
 175+ $this->getSpecializedWhereClause( $dbr ) .
 176+ ' )';
179177 // No path; count of code_rev
180178 } else {
181 - $sql .= ' WHERE cr_repo_id = ' . $this->mRepo->getId() .
182 - $this->getSpecializedWhereClause($dbr);
 179+ $whereCond = 'cr_repo_id = ' . $this->mRepo->getId() .
 180+ $this->getSpecializedWhereClause( $dbr );
183181 }
184 - return $dbr->query($sql);
 182+ return $dbr->selectRow ($tables, $selectFields, $whereCond);
185183 }
186184
187 - function getSpecializedWhereClause($dbr) {
 185+ function getSpecializedWhereClause( $dbr ) {
188186 return '';
189187 }
190188
Index: trunk/extensions/CodeReview/ui/CodeRevisionStatusView.php
@@ -10,8 +10,8 @@
1111 return new SvnRevStatusTablePager( $this, $this->mStatus );
1212 }
1313
14 - function getSpecializedWhereClause($dbr) {
15 - return ' AND cr_status = ' . $dbr->addQuotes($this->mStatus);
 14+ function getSpecializedWhereClause( $dbr ) {
 15+ return ' AND cr_status = ' . $dbr->addQuotes( $this->mStatus );
1616 }
1717 }
1818

Comments

#Comment by Bryan (talk | contribs)   14:33, 2 February 2010

I would include the total revision count in the message.

wfMsgExt( 'code-rev-total', 'parse', $revCount ) with code-rev-total "Total number of results: $1" or something

#Comment by Simetrical (talk | contribs)   17:45, 2 February 2010

Also, <strong> is probably better here than <span style="font-weight: bold">.

#Comment by Tim Starling (talk | contribs)   05:36, 16 February 2010

Marking fixme since I agree with the comments above.

Status & tagging log