r114676 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114675‎ | r114676 | r114677 >
Date:23:50, 2 April 2012
Author:bsitu
Status:deferred
Tags:
Comment:
format the date in stats nav
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.i18n.php (modified) (history)
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.stats.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/PageTriage.i18n.php
@@ -51,6 +51,7 @@
5252 'pagetriage-filter-blocked' => 'Are by blocked users',
5353 'pagetriage-filter-set-button' => 'Set Filters',
5454 'pagetriage-stats-untriaged-age' => 'Article Ages: Average: $1, Oldest: $2',
 55+ 'pagetriage-stats-less-than-a-day' => 'less than one day'
5556 );
5657
5758 /**
@@ -94,4 +95,5 @@
9596 'pagetriage-filter-blocked' => 'Checkbox text for articles by blocked users',
9697 'pagetriage-filter-set-button' => 'Button text for the set filter button',
9798 '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}} '
98100 );
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -237,6 +237,8 @@
238238 'pagetriage-filter-blocked',
239239 'pagetriage-filter-set-button',
240240 'pagetriage-stats-untriaged-age',
 241+ 'pagetriage-stats-less-than-a-day',
 242+ 'days',
241243 )
242244 );
243245
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.stats.js
@@ -14,14 +14,39 @@
1515 },
1616
1717 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'] ) );
2521 },
 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+
2651 url: mw.util.wikiScript( 'api' ) + '?action=pagetriagestats&format=json',
2752
2853 parse: function( response ) {

Status & tagging log