Index: trunk/extensions/PageTriage/PageTriage.i18n.php |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | 'pagetriage-filter-blocked' => 'Are by blocked users', |
53 | 53 | 'pagetriage-filter-set-button' => 'Set Filters', |
54 | 54 | 'pagetriage-stats-untriaged-age' => 'Article Ages: Average: $1, Oldest: $2', |
| 55 | + 'pagetriage-stats-less-than-a-day' => 'less than one day' |
55 | 56 | ); |
56 | 57 | |
57 | 58 | /** |
— | — | @@ -94,4 +95,5 @@ |
95 | 96 | 'pagetriage-filter-blocked' => 'Checkbox text for articles by blocked users', |
96 | 97 | 'pagetriage-filter-set-button' => 'Button text for the set filter button', |
97 | 98 | 'pagetriage-stats-untriaged-age' => 'Navigation text displaying triage stats', |
| 99 | + '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}} ' |
98 | 100 | ); |
Index: trunk/extensions/PageTriage/PageTriage.php |
— | — | @@ -237,6 +237,8 @@ |
238 | 238 | 'pagetriage-filter-blocked', |
239 | 239 | 'pagetriage-filter-set-button', |
240 | 240 | 'pagetriage-stats-untriaged-age', |
| 241 | + 'pagetriage-stats-less-than-a-day', |
| 242 | + 'days', |
241 | 243 | ) |
242 | 244 | ); |
243 | 245 | |
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.stats.js |
— | — | @@ -14,14 +14,39 @@ |
15 | 15 | }, |
16 | 16 | |
17 | 17 | formatMetadata: function ( stats ) { |
18 | | - stats.set( 'ptr_untriaged_article_count', stats.get( 'untriagedarticle' )['count'] ); |
19 | | - stats.set( 'ptrAverage', |
20 | | - stats.get( 'untriagedarticle' )['age-50th-percentile'] ? |
21 | | - stats.get( 'untriagedarticle' )['age-50th-percentile'] : '' ); |
22 | | - stats.set( 'ptrOldest', |
23 | | - stats.get( 'untriagedarticle' )['age-100th-percentile'] ? |
24 | | - stats.get( 'untriagedarticle' )['age-100th-percentile'] : '' ); |
| 18 | + stats.set( 'ptr_untriaged_article_count', stats.get( 'untriagedarticle' )['count'] ); |
| 19 | + stats.set( 'ptrAverage', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-50th-percentile'] ) ); |
| 20 | + stats.set( 'ptrOldest', this.formatDaysFromNow( stats.get( 'untriagedarticle' )['age-100th-percentile'] ) ); |
25 | 21 | }, |
| 22 | + |
| 23 | + formatDaysFromNow: function ( dateStr ) { |
| 24 | + if ( !dateStr ) { |
| 25 | + return ''; |
| 26 | + } |
| 27 | + |
| 28 | + 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(), |
| 36 | + now.getUTCSeconds() |
| 37 | + ) |
| 38 | + ); |
| 39 | + |
| 40 | + var begin = Date.parseExact( dateStr, 'yyyyMMddHHmmss' ); |
| 41 | + begin.setTimezone( 'GMT' ); |
| 42 | + |
| 43 | + var diff = Math.round( ( now.getTime() - begin.getTime() ) / ( 1000 * 60 * 60 * 24 ) ); |
| 44 | + if ( diff ) { |
| 45 | + return gM( 'days', diff ); |
| 46 | + } else { |
| 47 | + return gM( 'pagetriage-stats-less-than-a-day', diff ); |
| 48 | + } |
| 49 | + }, |
| 50 | + |
26 | 51 | url: mw.util.wikiScript( 'api' ) + '?action=pagetriagestats&format=json', |
27 | 52 | |
28 | 53 | parse: function( response ) { |