r96327 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96326‎ | r96327 | r96328 >
Date:13:16, 6 September 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
* (bug 29292) Wall of shame per path

Paths will probably want de-regexifying
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/RepoStats.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRepoStatsView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -241,6 +241,13 @@
242242 $wgCodeReviewAutoTagPath = array();
243243
244244 /**
 245+ * Key is repository name. Value is an array of key value pairs of the paths to get fixme list for
 246+ *
 247+ * $wgCodeReviewFixmePerPath = array( 'RepoName' => array( '%^/path/to/use%', '%^/another/path/to/use%' ) )
 248+ */
 249+$wgCodeReviewFixmePerPath = array();
 250+
 251+/**
245252 * UDP comment and status changes notification
246253 */
247254 $wgCodeReviewUDPAddress = false;
Index: trunk/extensions/CodeReview/backend/RepoStats.php
@@ -16,6 +16,8 @@
1717 $fixmes,
1818 $new;
1919
 20+ public $fixmesPerPath;
 21+
2022 /**
2123 * @param CodeRepository $repo
2224 * @return RepoStats
@@ -74,7 +76,13 @@
7577
7678 $this->fixmes = $this->getAuthorStatusCounts( 'fixme' );
7779 $this->new = $this->getAuthorStatusCounts( 'new' );
78 -
 80+ $this->fixmesPerPath = array();
 81+ global $wgCodeReviewFixmePerPath;
 82+ if ( isset( $wgCodeReviewFixmePerPath[ $this->repo->getName() ] ) ) {
 83+ foreach( $wgCodeReviewFixmePerPath[ $this->repo->getName() ] as $path ) {
 84+ $this->fixmesPerPath[$path] = $this->getPathFixmes( $path );
 85+ }
 86+ }
7987 wfProfileOut( __METHOD__ );
8088 }
8189
@@ -101,4 +109,35 @@
102110 }
103111 return $array;
104112 }
 113+
 114+ /**
 115+ * @param $path path to get fixmes for
 116+ * @return array
 117+ */
 118+ private function getPathFixmes( $path ) {
 119+ $array = array();
 120+ $dbr = wfGetDB( DB_SLAVE );
 121+ $res = $dbr->select(
 122+ array( 'code_paths', 'code_rev' ),
 123+ array( 'COUNT(*) AS revs', 'cr_author' ),
 124+ array(
 125+ 'cr_repo_id' => $this->repo->getId(),
 126+ 'cp_path' => $path,
 127+ 'cr_status' => 'fixme',
 128+ ),
 129+ __METHOD__,
 130+ array(
 131+ 'GROUP BY' => 'cr_author',
 132+ 'ORDER BY' => 'revs DESC',
 133+ 'LIMIT' => 500,
 134+ ),
 135+ array(
 136+ 'code_rev' => array( 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' )
 137+ )
 138+ );
 139+ foreach ( $res as $row ) {
 140+ $array[$row->cr_author] = $row->revs;
 141+ }
 142+ return $array;
 143+ }
105144 }
\ No newline at end of file
Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -208,6 +208,8 @@
209209 'code-stats-main' => 'As of $1, the repository has $2 {{PLURAL:$2|revision|revisions}} by [[Special:Code/$3/author|$4 {{PLURAL:$4|author|authors}}]].',
210210 'code-stats-status-breakdown' => 'Number of revisions per state',
211211 'code-stats-fixme-breakdown' => 'Breakdown of fixme revisions per author',
 212+ 'code-stats-fixme-breakdown-path' => 'Breakdown of fixme revisions per path',
 213+ 'code-stats-fixme-path' => 'Fixme revisions for path: $1',
212214 'code-stats-new-breakdown' => 'Breakdown of new revisions per author',
213215 'code-stats-count' => 'Number of revisions',
214216
Index: trunk/extensions/CodeReview/ui/CodeRepoStatsView.php
@@ -47,6 +47,15 @@
4848 if ( !empty( $stats->new ) ) {
4949 $this->writeAuthorStatusTable( 'new', $stats->new );
5050 }
 51+
 52+ if ( !empty( $stats->fixmesPerPath ) ) {
 53+ $wgOut->wrapWikiMsg( "<h3 id=\"stats-fixme-path\">$1</h3>", 'code-stats-fixme-breakdown-path' );
 54+
 55+ foreach ( $stats->fixmesPerPath as $path => $fixmes ) {
 56+ $wgOut->wrapWikiMsg( "<h4 id=\"stats-fixme-path\">$1</h4>", 'code-stats-fixme-path', $path );
 57+ $this->writeAuthorTable( 'fixme', $fixmes, array( 'path' => $path ) );
 58+ }
 59+ }
5160 }
5261
5362 /**
@@ -54,20 +63,32 @@
5564 * @param $array array
5665 */
5766 function writeAuthorStatusTable( $status, $array ) {
 67+ global $wgOut;
 68+ $wgOut->wrapWikiMsg( "<h3 id=\"stats-{$status}\">$1</h3>", "code-stats-{$status}-breakdown" );
 69+ $this->writeAuthorTable( $status, $array );
 70+ }
 71+
 72+ /**
 73+ * @param $status string
 74+ * @param $array array
 75+ * @param $options array
 76+ */
 77+ function writeAuthorTable( $status, $array, $options = array() ) {
5878 global $wgOut, $wgLang;
 79+
5980 $repoName = $this->mRepo->getName();
60 - $wgOut->wrapWikiMsg( "<h3 id=\"stats-{$status}\">$1</h3>", "code-stats-{$status}-breakdown" );
6181 $wgOut->addHTML( '<table class="wikitable">'
6282 . '<tr><th>' . wfMsgHtml( 'code-field-author' ) . '</th><th>'
6383 . wfMsgHtml( 'code-stats-count' ) . '</th></tr>' );
6484 $title = SpecialPage::getTitleFor( 'Code', $repoName . "/status/{$status}" );
 85+
6586 foreach ( $array as $user => $count ) {
6687 $count = htmlspecialchars( $wgLang->formatNum( $count ) );
6788 $link = $this->skin->link(
6889 $title,
6990 htmlspecialchars( $user ),
7091 array(),
71 - array( 'author' => $user )
 92+ array_merge( $options, array( 'author' => $user ) )
7293 );
7394 $wgOut->addHTML( "<tr><td>$link</td>"
7495 . "<td>$count</td></tr>" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96331Followup r96327...reedy13:32, 6 September 2011

Comments

#Comment by Hashar (talk | contribs)   12:27, 7 September 2011

\o/

Status & tagging log