Index: trunk/extensions/PageTriage/SpecialPageTriage.php |
— | — | @@ -228,7 +228,12 @@ |
229 | 229 | </script> |
230 | 230 | |
231 | 231 | <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> |
233 | 238 | </script> |
234 | 239 | |
235 | 240 | HTML; |
Index: trunk/extensions/PageTriage/includes/PageTriageUtil.php |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | * last-day, last-week, last-month, last-year |
95 | 95 | * @return array |
96 | 96 | */ |
97 | | - public static function getTopTriager( $time = 'last-day' ) { |
| 97 | + public static function getTopTriager( $time = 'last-week' ) { |
98 | 98 | global $wgMemc; |
99 | 99 | |
100 | 100 | $now = wfTimestamp( TS_UNIX ); |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | if ( $topTriager === false ) { |
120 | 120 | $res = $dbr->select( |
121 | 121 | array( 'pagetriage_log', 'user' ), |
122 | | - array( 'user_name', 'COUNT(ptrl_id) AS num' ), |
| 122 | + array( 'user_name', 'user_id', 'COUNT(ptrl_id) AS num' ), |
123 | 123 | array( 'user_id = ptrl_user_id', 'ptrl_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $timeFrame[$time]['ts'] ) ) ), |
124 | 124 | __METHOD__, |
125 | 125 | 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 @@ |
15 | 15 | }, |
16 | 16 | |
17 | 17 | 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' ) ) ); |
19 | 20 | stats.set( 'ptrAverage', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-50th-percentile'] ) ); |
20 | 21 | stats.set( 'ptrOldest', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-100th-percentile'] ) ); |
21 | 22 | }, |
22 | | - |
| 23 | + |
23 | 24 | formatDaysFromNow: function ( dateStr ) { |
24 | 25 | if ( !dateStr ) { |
25 | 26 | return ''; |
26 | 27 | } |
27 | 28 | |
28 | 29 | 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(), |
36 | 37 | now.getUTCSeconds() |
37 | | - ) |
| 38 | + ) |
38 | 39 | ); |
39 | | - |
| 40 | + |
40 | 41 | var begin = Date.parseExact( dateStr, 'yyyyMMddHHmmss' ); |
41 | 42 | begin.setTimezone( 'GMT' ); |
42 | | - |
| 43 | + |
43 | 44 | var diff = Math.round( ( now.getTime() - begin.getTime() ) / ( 1000 * 60 * 60 * 24 ) ); |
44 | 45 | if ( diff ) { |
45 | 46 | return gM( 'days', diff ); |
— | — | @@ -47,6 +48,22 @@ |
48 | 49 | } |
49 | 50 | }, |
50 | 51 | |
| 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 | + |
51 | 68 | url: mw.util.wikiScript( 'api' ) + '?action=pagetriagestats&format=json', |
52 | 69 | |
53 | 70 | parse: function( response ) { |
Index: trunk/extensions/PageTriage/api/ApiPageTriageStats.php |
— | — | @@ -3,9 +3,18 @@ |
4 | 4 | class ApiPageTriageStats extends ApiBase { |
5 | 5 | |
6 | 6 | 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 | + ) |
10 | 19 | ); |
11 | 20 | |
12 | 21 | $result = array( 'result' => 'success', 'stats' => $data ); |
Index: trunk/extensions/PageTriage/PageTriage.i18n.php |
— | — | @@ -52,6 +52,7 @@ |
53 | 53 | 'pagetriage-filter-set-button' => 'Set Filters', |
54 | 54 | 'pagetriage-stats-untriaged-age' => 'Article Ages: Average: $1, Oldest: $2', |
55 | 55 | 'pagetriage-stats-less-than-a-day' => 'less than one day', |
| 56 | + 'pagetriage-stats-top-triagers' => 'Top {{PLURAL:$1|triager|$1 triagers}}: $2', |
56 | 57 | 'pagetriage-filter-ns-article' => 'Article', |
57 | 58 | ); |
58 | 59 | |
— | — | @@ -95,7 +96,8 @@ |
96 | 97 | 'pagetriage-filter-non-autoconfirmed' => 'Checkbox text for articles by non-Autoconfirmed users', |
97 | 98 | 'pagetriage-filter-blocked' => 'Checkbox text for articles by blocked users', |
98 | 99 | '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', |
100 | 101 | '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', |
101 | 103 | 'pagetriage-filter-ns-article' => 'The name of the main article namespace', |
102 | 104 | ); |
Index: trunk/extensions/PageTriage/PageTriage.php |
— | — | @@ -239,6 +239,8 @@ |
240 | 240 | 'pagetriage-filter-set-button', |
241 | 241 | 'pagetriage-stats-untriaged-age', |
242 | 242 | 'pagetriage-stats-less-than-a-day', |
| 243 | + 'pagetriage-stats-top-triagers', |
| 244 | + 'days', |
243 | 245 | 'pagetriage-filter-ns-article', |
244 | 246 | ) |
245 | 247 | ); |