r69933 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69932‎ | r69933 | r69934 >
Date:08:12, 26 July 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Display Total number of authors on Special:Code/repo/author
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeAuthorListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -43,6 +43,7 @@
4444 'code-author-unlink' => 'unlink?',
4545 'code-author-unlinksuccess' => 'Author $1 has been unlinked',
4646 'code-author-badtoken' => 'Session error trying to perform the action.',
 47+ 'code-author-total' => 'Total number of authors: $1',
4748 'code-browsing-path' => "Browsing revisions in '''$1'''",
4849 'code-field-id' => 'Revision',
4950 'code-field-author' => 'Author',
Index: trunk/extensions/CodeReview/ui/CodeAuthorListView.php
@@ -11,7 +11,8 @@
1212 global $wgOut;
1313 $authors = $this->mRepo->getAuthorList();
1414 $repo = $this->mRepo->getName();
15 - $text = wfMsg( 'code-authors-text' ) . "\n";
 15+ $text = wfMsg( 'code-authors-text' ) . "\n\n";
 16+ $text .= '<strong>' . wfMsg( 'code-author-total', count( $authors ) ) . "</strong>\n";
1617 foreach ( $authors as $committer ) {
1718 if ( $committer ) {
1819 $text .= "* [[Special:Code/$repo/author/$committer|$committer]]";

Follow-up revisions

RevisionCommit summaryAuthorDate
r69937Followup r69933...reedy10:20, 26 July 2010
r74074Use getAuthorCount() instead of counting authors (followup r69933, r70827)demon16:02, 1 October 2010

Comments

#Comment by MaxSem (talk | contribs)   10:12, 26 July 2010

The problem is that the query that produces the authors list has LIMIT 500, so eventually this number will be incorrect.

#Comment by MaxSem (talk | contribs)   10:17, 26 July 2010

Additionally, you should use $wgLang->formatNum() to display numbers.

#Comment by Reedy (talk | contribs)   10:17, 26 July 2010

Does that list paginate at all? As if not, that's a problem also.. (I'm guessing it doesn't)


mysql> SELECT COUNT(ca_author) FROM code_authors WHERE ca_repo_id = 1; +------------------+ | COUNT(ca_author) | +------------------+ | 200 | +------------------+ 1 row in set (0.00 sec)


Though, I've noticed that isn't populated on my test install...

We could query that, and cache for a similar length as the user list...?


#Comment by Reedy (talk | contribs)   10:29, 26 July 2010

Also, what about:

	public function getAuthorCount() {
		global $wgMemc;
		$key = wfMemcKey( 'codereview', 'authorcount', $this->getId() );
		$authorsCount = $wgMemc->get( $key );
		if ( is_int( $authorsCount ) ) {
			return $authorsCount;
		}
		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select(
			'code_authors',
			array( 'COUNT(cr_author) AS author_count' ),
			array( 'cr_repo_id' => $this->getId() ),
			__METHOD__,
		);

		if ( !$row ) {
			throw new MWException( 'Failed to load expected author count' );
		}
		
		$authorcount = $row->author_count;
		
		$wgMemc->set( $key, $authorcount, 3600 * 24 );
		return $authorcount;
	}
#Comment by Reedy (talk | contribs)   10:32, 26 July 2010

Though, the code_authors only seems to be populated at point of linking... :/

#Comment by Reedy (talk | contribs)   10:55, 26 July 2010

SELECT COUNT(DISTINCT cr_author) FROM mw_code_rev;

is the other option. But I bet it's unindexed, and will make domas unhappy

mysql> DESCRIBE SELECT COUNT(DISTINCT cr_author) FROM mw_code_rev;
+----+-------------+-------------+-------+---------------+----------------+---------+------+-------+-------------+
| id | select_type | table       | type  | possible_keys | key            | key_len | ref  | rows  | Extra       |
+----+-------------+-------------+-------+---------------+----------------+---------+------+-------+-------------+
|  1 | SIMPLE      | mw_code_rev | index | NULL          | cr_repo_author | 276     | NULL | 80602 | Using index |
+----+-------------+-------------+-------+---------------+----------------+---------+------+-------+-------------+
1 row in set (0.00 sec)
#Comment by Bryan (talk | contribs)   17:47, 26 July 2010

Write a maintenance script that populates code_authors from code_rev with ca_user_text = NULL

#Comment by Reedy (talk | contribs)   13:02, 26 July 2010

Noticed what I posted above was wrong (mix of $res and $row), but blah

#Comment by 😂 (talk | contribs)   16:08, 1 October 2010

code_authors is only for the ones that have been linked.

Could probably ditch the LIMIT 500, we've got an index on this.

Status & tagging log