r114684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114683‎ | r114684 | r114685 >
Date:18:05, 3 April 2012
Author:bsitu
Status:deferred
Tags:
Comment:
Display top 5 triagers at nav bar
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.i18n.php (modified) (history)
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/SpecialPageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/api/ApiPageTriageStats.php (modified) (history)
  • /trunk/extensions/PageTriage/includes/PageTriageUtil.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.stats.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -228,7 +228,12 @@
229229 </script>
230230
231231 <script type="text/template" id="listStatsNavTemplate">
232 - <% if ( ptrAverage ) { %> <%= gM( 'pagetriage-stats-untriaged-age', ptrAverage, ptrOldest ) %> <% } %>
 232+ <div id="mwe-pt-top-triager">
 233+ <%= ptrTopTriager %>
 234+ </div>
 235+ <div id="mwe-pt-article-age-stats">
 236+ <% if ( ptrAverage ) { %> <%= gM( 'pagetriage-stats-untriaged-age', ptrAverage, ptrOldest ) %> <% } %>
 237+ </div>
233238 </script>
234239
235240 HTML;
Index: trunk/extensions/PageTriage/includes/PageTriageUtil.php
@@ -93,7 +93,7 @@
9494 * last-day, last-week, last-month, last-year
9595 * @return array
9696 */
97 - public static function getTopTriager( $time = 'last-day' ) {
 97+ public static function getTopTriager( $time = 'last-week' ) {
9898 global $wgMemc;
9999
100100 $now = wfTimestamp( TS_UNIX );
@@ -118,7 +118,7 @@
119119 if ( $topTriager === false ) {
120120 $res = $dbr->select(
121121 array( 'pagetriage_log', 'user' ),
122 - array( 'user_name', 'COUNT(ptrl_id) AS num' ),
 122+ array( 'user_name', 'user_id', 'COUNT(ptrl_id) AS num' ),
123123 array( 'user_id = ptrl_user_id', 'ptrl_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $timeFrame[$time]['ts'] ) ) ),
124124 __METHOD__,
125125 array( 'GROUP BY' => 'user_id', 'ORDER BY' => 'num DESC', 'LIMIT' => 50 )
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.stats.js
@@ -14,31 +14,32 @@
1515 },
1616
1717 formatMetadata: function ( stats ) {
18 - stats.set( 'ptr_untriaged_article_count', stats.get( 'untriagedarticle' )['count'] );
 18+ stats.set( 'ptr_untriaged_article_count', stats.get( 'untriagedarticle' )['count'] );
 19+ stats.set( 'ptrTopTriager', this.formatTopTriager( stats.get( 'toptriager' ) ) );
1920 stats.set( 'ptrAverage', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-50th-percentile'] ) );
2021 stats.set( 'ptrOldest', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-100th-percentile'] ) );
2122 },
22 -
 23+
2324 formatDaysFromNow: function ( dateStr ) {
2425 if ( !dateStr ) {
2526 return '';
2627 }
2728
2829 var now = new Date();
29 - now = new Date(
30 - Date.UTC(
31 - now.getUTCFullYear(),
32 - now.getUTCMonth(),
33 - now.getUTCDate(),
34 - now.getUTCHours(),
35 - now.getUTCMinutes(),
 30+ now = new Date(
 31+ Date.UTC(
 32+ now.getUTCFullYear(),
 33+ now.getUTCMonth(),
 34+ now.getUTCDate(),
 35+ now.getUTCHours(),
 36+ now.getUTCMinutes(),
3637 now.getUTCSeconds()
37 - )
 38+ )
3839 );
39 -
 40+
4041 var begin = Date.parseExact( dateStr, 'yyyyMMddHHmmss' );
4142 begin.setTimezone( 'GMT' );
42 -
 43+
4344 var diff = Math.round( ( now.getTime() - begin.getTime() ) / ( 1000 * 60 * 60 * 24 ) );
4445 if ( diff ) {
4546 return gM( 'days', diff );
@@ -47,6 +48,22 @@
4849 }
4950 },
5051
 52+ formatTopTriager: function ( topTriager ) {
 53+ if ( topTriager.total > 0 ) {
 54+ var topTriagerList = '';
 55+ for ( var key in topTriager.data ) {
 56+ if ( topTriagerList ) {
 57+ topTriagerList += ', ' + topTriager.data[key].user_name;
 58+ } else {
 59+ topTriagerList += topTriager.data[key].user_name;
 60+ }
 61+ }
 62+ return gM( 'pagetriage-stats-top-triagers', Number( topTriager.total ), topTriagerList );
 63+ } else {
 64+ return '';
 65+ }
 66+ },
 67+
5168 url: mw.util.wikiScript( 'api' ) + '?action=pagetriagestats&format=json',
5269
5370 parse: function( response ) {
Index: trunk/extensions/PageTriage/api/ApiPageTriageStats.php
@@ -3,9 +3,18 @@
44 class ApiPageTriageStats extends ApiBase {
55
66 public function execute() {
7 - $data = array(
8 - 'untriagedarticle' => PageTriageUtil::getUntriagedArticleStat(),
9 - 'toptriager' => PageTriageUtil::getTopTriager()
 7+ $topTriager = PageTriageUtil::getTopTriager();
 8+ // Grab at most top 5 from cache
 9+ if ( count( $topTriager ) > 5 ) {
 10+ $topTriager = array_slice( PageTriageUtil::getTopTriager(), 0 , 5 );
 11+ }
 12+
 13+ $data = array(
 14+ 'untriagedarticle' => PageTriageUtil::getUntriagedArticleStat(),
 15+ 'toptriager' => array(
 16+ 'total' => count( $topTriager ),
 17+ 'data' => $topTriager
 18+ )
1019 );
1120
1221 $result = array( 'result' => 'success', 'stats' => $data );
Index: trunk/extensions/PageTriage/PageTriage.i18n.php
@@ -52,6 +52,7 @@
5353 'pagetriage-filter-set-button' => 'Set Filters',
5454 'pagetriage-stats-untriaged-age' => 'Article Ages: Average: $1, Oldest: $2',
5555 'pagetriage-stats-less-than-a-day' => 'less than one day',
 56+ 'pagetriage-stats-top-triagers' => 'Top {{PLURAL:$1|triager|$1 triagers}}: $2',
5657 'pagetriage-filter-ns-article' => 'Article',
5758 );
5859
@@ -95,7 +96,8 @@
9697 'pagetriage-filter-non-autoconfirmed' => 'Checkbox text for articles by non-Autoconfirmed users',
9798 'pagetriage-filter-blocked' => 'Checkbox text for articles by blocked users',
9899 'pagetriage-filter-set-button' => 'Button text for the set filter button',
99 - 'pagetriage-stats-untriaged-age' => 'Navigation text displaying triage stats',
 100+ 'pagetriage-stats-untriaged-age' => 'Navigation text displaying triage stats, $1 and $2 are the ages of average and oldest articles respectively',
100101 'pagetriage-stats-less-than-a-day' => 'show this message if the article age is less than one day, part of variable $1 and $2 of {{msg-pagetriage|pagetriage-stats-untriaged-age}} ',
 102+ 'pagetriage-stats-top-triagers' => 'Text that shows top triagers, $1 is the total number, $2 shows the detail',
101103 'pagetriage-filter-ns-article' => 'The name of the main article namespace',
102104 );
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -239,6 +239,8 @@
240240 'pagetriage-filter-set-button',
241241 'pagetriage-stats-untriaged-age',
242242 'pagetriage-stats-less-than-a-day',
 243+ 'pagetriage-stats-top-triagers',
 244+ 'days',
243245 'pagetriage-filter-ns-article',
244246 )
245247 );

Status & tagging log