Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -248,6 +248,7 @@ |
249 | 249 | $wgAutoloadClasses['FlaggedPageConfig'] = $accessDir . 'FlaggedPageConfig.php'; |
250 | 250 | $wgAutoloadClasses['FlaggedRevsLog'] = $accessDir . 'FlaggedRevsLog.php'; |
251 | 251 | $wgAutoloadClasses['FRInclusionCache'] = $accessDir . 'FRInclusionCache.php'; |
| 252 | +$wgAutoloadClasses['FlaggedRevsStats'] = $accessDir . 'FlaggedRevsStats.php'; |
252 | 253 | # Data object classes... |
253 | 254 | $wgAutoloadClasses['FRExtraCacheUpdate'] = $accessDir . 'FRExtraCacheUpdate.php'; |
254 | 255 | $wgAutoloadClasses['FRExtraCacheUpdateJob'] = $accessDir . 'FRExtraCacheUpdate.php'; |
Index: trunk/extensions/FlaggedRevs/schema/mysql/FlaggedRevs.sql |
— | — | @@ -139,16 +139,14 @@ |
140 | 140 | frp_user_params mediumblob NOT NULL |
141 | 141 | ) /*$wgDBTableOptions*/; |
142 | 142 | |
143 | | -CREATE TABLE /*_*/flaggedrevs_stats ( |
144 | | - namespace int unsigned NOT NULL DEFAULT 0 PRIMARY KEY, |
145 | | - total int unsigned NOT NULL DEFAULT 0, |
146 | | - reviewed int unsigned NOT NULL DEFAULT 0, |
147 | | - synced int unsigned NOT NULL DEFAULT 0 |
| 143 | +-- This stores overall stats |
| 144 | +CREATE TABLE /*_*/flaggedrevs_statistics ( |
| 145 | + -- Timestamp stat was recorded |
| 146 | + frs_timestamp varbinary(14) NOT NULL, |
| 147 | + -- Stat key name, colons separate paramaters |
| 148 | + frs_stat_key varchar(255) NOT NULL, |
| 149 | + -- Stat value as an integer |
| 150 | + frs_stat_val integer unsigned NOT NULL, |
| 151 | + PRIMARY KEY(frs_stat_key,frs_timestamp) |
148 | 152 | ) /*$wgDBTableOptions*/; |
149 | | - |
150 | | -CREATE TABLE /*_*/flaggedrevs_stats2 ( |
151 | | - stat_id int unsigned NOT NULL DEFAULT 1 PRIMARY KEY, |
152 | | - ave_review_time int unsigned NOT NULL DEFAULT 0, |
153 | | - med_review_time int unsigned NOT NULL DEFAULT 0, |
154 | | - ave_pending_time int unsigned NOT NULL DEFAULT 0 |
155 | | -) /*$wgDBTableOptions*/; |
| 153 | +CREATE INDEX /*i*/frs_timestamp ON /*_*/flaggedrevs_statistics (frs_timestamp); |
Index: trunk/extensions/FlaggedRevs/schema/mysql/patch-flaggedrevs_statistics.sql |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +-- old format -- |
| 3 | +DROP TABLE IF EXISTS /*_*/flaggedrevs_stats; |
| 4 | +DROP TABLE IF EXISTS /*_*/flaggedrevs_stats2; |
| 5 | + |
| 6 | +-- This stores overall stats |
| 7 | +CREATE TABLE /*_*/flaggedrevs_statistics ( |
| 8 | + -- Timestamp stat was recorded |
| 9 | + frs_timestamp varbinary(14) NOT NULL, |
| 10 | + -- Stat key name, colons separate paramaters |
| 11 | + frs_stat_key varchar(255) NOT NULL, |
| 12 | + -- Stat value as an integer |
| 13 | + frs_stat_val integer unsigned NOT NULL, |
| 14 | + PRIMARY KEY(frs_stat_key,frs_timestamp) |
| 15 | +) /*$wgDBTableOptions*/; |
| 16 | +CREATE INDEX /*i*/frs_timestamp ON /*_*/flaggedrevs_statistics (frs_timestamp); |
Property changes on: trunk/extensions/FlaggedRevs/schema/mysql/patch-flaggedrevs_statistics.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 17 | + native |
Index: trunk/extensions/FlaggedRevs/schema/FlaggedRevsUpdater.hooks.php |
— | — | @@ -29,12 +29,12 @@ |
30 | 30 | 'flaggedpage_config', 'fpc_level', "$base/patch-fpc_level.sql", true ) ); |
31 | 31 | $du->addExtensionUpdate( array( 'addTable', |
32 | 32 | 'flaggedpage_pending', "$base/patch-flaggedpage_pending.sql", true ) ); |
33 | | - $du->addExtensionUpdate( array( 'addTable', |
34 | | - 'flaggedrevs_stats', "$base/patch-flaggedrevs_stats.sql", true ) ); |
35 | 33 | $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedImagesTimestampNULL', |
36 | 34 | "$base/patch-fi_img_timestamp.sql" ) ); |
37 | 35 | $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedRevsRevTimestamp', |
38 | 36 | "$base/patch-fr_page_rev-index.sql" ) ); |
| 37 | + $du->addExtensionUpdate( array( 'addTable', |
| 38 | + 'flaggedrevs_statistics', "$base/patch-flaggedrevs_statistics.sql", true ) ); |
39 | 39 | } elseif ( $wgDBtype == 'postgres' ) { |
40 | 40 | $base = dirname( __FILE__ ) . '/postgres'; |
41 | 41 | // Initial install tables (current schema) |
— | — | @@ -59,11 +59,12 @@ |
60 | 60 | 'flaggedpage_config', 'fpc_level', "TEXT NULL" ) ); |
61 | 61 | $du->addExtensionUpdate( array( 'addTable', |
62 | 62 | 'flaggedpage_pending', "$base/patch-flaggedpage_pending.sql", true ) ); |
63 | | - // @TODO: PG stats table??? |
64 | 63 | $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedImagesTimestampNULL', |
65 | 64 | "$base/patch-fi_img_timestamp.sql" ) ); |
66 | 65 | $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedRevsRevTimestamp', |
67 | 66 | "$base/patch-fr_page_rev-index.sql" ) ); |
| 67 | + $du->addExtensionUpdate( array( 'addTable', |
| 68 | + 'flaggedrevs_statistics', "$base/patch-flaggedrevs_statistics.sql", true ) ); |
68 | 69 | } elseif ( $wgDBtype == 'sqlite' ) { |
69 | 70 | $base = dirname( __FILE__ ) . '/mysql'; |
70 | 71 | $du->addExtensionUpdate( array( 'addTable', |
Index: trunk/extensions/FlaggedRevs/schema/postgres/patch-flaggedrevs_statistics.sql |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +-- old format -- |
| 3 | +DROP TABLE IF EXISTS flaggedrevs_stats; |
| 4 | +DROP TABLE IF EXISTS flaggedrevs_stats2; |
| 5 | + |
| 6 | +CREATE TABLE flaggedrevs_statistics ( |
| 7 | + frs_timestamp TIMESTAMPTZ NOT NULL, |
| 8 | + frs_stat_key TEXT NOT NULL, |
| 9 | + frs_stat_val BIGINT NOT NULL, |
| 10 | + PRIMARY KEY(frs_stat_key,frs_timestamp) |
| 11 | +) /*$wgDBTableOptions*/; |
| 12 | +CREATE INDEX frs_timestamp ON flaggedrevs_statistics (frs_timestamp); |
Property changes on: trunk/extensions/FlaggedRevs/schema/postgres/patch-flaggedrevs_statistics.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 13 | + native |
Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc |
— | — | @@ -52,51 +52,62 @@ |
53 | 53 | array( 'USE INDEX' => array('flaggedpages' => 'fp_pending_since') ) |
54 | 54 | ); |
55 | 55 | # Get wait times for anon edits... |
56 | | - list( $aveRT, $medianRT, $rPerTable ) = getAveReviewTimesAnons( $dbr, $dbCache ); |
| 56 | + list( $aveRT, $medianRT, $rPerTable, $rSize ) = getAveReviewTimesAnons( $dbr, $dbCache ); |
57 | 57 | |
58 | 58 | // Save the data... |
59 | | - // @TODO: new permanent schema |
60 | 59 | #echo "\nAve=".($aveRT/3600)." Med=".($medianRT/3600)."\n"; |
61 | 60 | $dbw = wfGetDB( DB_MASTER ); |
62 | | - // Make sure the master has flaggedrevs_stats and _stats2 |
63 | | - if ( !$dbw->tableExists( 'flaggedrevs_stats' ) || |
64 | | - !$dbw->tableExists( 'flaggedrevs_stats2' ) ) |
65 | | - { |
66 | | - print( "Need to run update.php to create flaggedrevs_stats and flaggedrevs_stats2. Stopping." ); |
67 | | - die( 1 ); |
| 61 | + // The timestamp to identify this whole batch of data |
| 62 | + $encDataTimestamp = $dbw->timestamp(); |
| 63 | + |
| 64 | + $dataSet = array(); |
| 65 | + // All-namespace percentiles... |
| 66 | + foreach( $rPerTable as $percentile => $seconds ) { |
| 67 | + $dataSet[] = array( |
| 68 | + 'frs_stat_key' => 'reviewLag-percentile:'.(int)$percentile, |
| 69 | + 'frs_stat_val' => $seconds, |
| 70 | + 'frs_timestamp' => $encDataTimestamp ); |
68 | 71 | } |
69 | | - $dbw->begin(); |
70 | | - // Save/cache percentiles |
71 | | - $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' ); |
72 | | - $dbCache->set( $key, $rPerTable, 30*24*3600 ); |
73 | | - // Per-namespace stats... |
| 72 | + // Sample size... |
| 73 | + $dataSet[] = array( |
| 74 | + 'frs_stat_key' => 'reviewLag-sampleSize', |
| 75 | + 'frs_stat_val' => $rSize, |
| 76 | + 'frs_timestamp' => $encDataTimestamp ); |
| 77 | + |
| 78 | + // All-namespace ave/med review lag & ave pending lag stats... |
| 79 | + $dataSet[] = array( |
| 80 | + 'frs_stat_key' => 'reviewLag-average', |
| 81 | + 'frs_stat_val' => $aveRT, |
| 82 | + 'frs_timestamp' => $encDataTimestamp ); |
| 83 | + $dataSet[] = array( |
| 84 | + 'frs_stat_key' => 'reviewLag-median', |
| 85 | + 'frs_stat_val' => $medianRT, |
| 86 | + 'frs_timestamp' => $encDataTimestamp ); |
| 87 | + $dataSet[] = array( |
| 88 | + 'frs_stat_key' => 'pendingLag-average', |
| 89 | + 'frs_stat_val' => $avePET, |
| 90 | + 'frs_timestamp' => $encDataTimestamp ); |
| 91 | + |
| 92 | + // Per-namespace total/reviewed/synced stats... |
74 | 93 | foreach( $wgFlaggedRevsNamespaces as $namespace ) { |
75 | | - $dbw->replace( 'flaggedrevs_stats', |
76 | | - array( 'namespace' ), |
77 | | - array( 'namespace' => intval($namespace), |
78 | | - 'total' => isset($ns_total[$namespace]) ? $ns_total[$namespace] : 0, |
79 | | - 'reviewed' => isset($ns_reviewed[$namespace]) ? $ns_reviewed[$namespace] : 0, |
80 | | - 'synced' => isset($ns_synced[$namespace]) ? $ns_synced[$namespace] : 0 |
81 | | - ), |
82 | | - __METHOD__ |
83 | | - ); |
| 94 | + $dataSet[] = array( |
| 95 | + 'frs_stat_key' => 'totalPages-NS:'.(int)$namespace, |
| 96 | + 'frs_stat_val' => isset($ns_total[$namespace]) ? $ns_total[$namespace] : 0, |
| 97 | + 'frs_timestamp' => $encDataTimestamp ); |
| 98 | + $dataSet[] = array( |
| 99 | + 'frs_stat_key' => 'reviewedPages-NS:'.(int)$namespace, |
| 100 | + 'frs_stat_val' => isset($ns_reviewed[$namespace]) ? $ns_reviewed[$namespace] : 0, |
| 101 | + 'frs_timestamp' => $encDataTimestamp ); |
| 102 | + $dataSet[] = array( |
| 103 | + 'frs_stat_key' => 'syncedPages-NS:'.(int)$namespace, |
| 104 | + 'frs_stat_val' => isset($ns_synced[$namespace]) ? $ns_synced[$namespace] : 0, |
| 105 | + 'frs_timestamp' => $encDataTimestamp ); |
84 | 106 | } |
85 | | - // Overall stats... |
86 | | - $dbw->replace( 'flaggedrevs_stats2', |
87 | | - array( 'stat_id' ), |
88 | | - array( 'stat_id' => 1, |
89 | | - 'ave_review_time' => $aveRT, |
90 | | - 'med_review_time' => $medianRT, |
91 | | - 'ave_pending_time' => $avePET |
92 | | - ), |
93 | | - __METHOD__ |
94 | | - ); |
95 | | - // Update timestamp |
96 | | - $dbw->replace( 'querycache_info', array('qci_type'), |
97 | | - array('qci_type' => 'validationstats', 'qci_timestamp' => $dbw->timestamp()), |
98 | | - __METHOD__ |
99 | | - ); |
| 107 | + |
| 108 | + $dbw->begin(); |
| 109 | + $dbw->insert( 'flaggedrevs_statistics', $dataSet, __FUNCTION__, array( 'IGNORE' ) ); |
100 | 110 | $dbw->commit(); |
| 111 | + |
101 | 112 | // Stats are now up to date! |
102 | 113 | $key = wfMemcKey( 'flaggedrevs', 'statsUpdated' ); |
103 | 114 | $dbCache->set( $key, '1', $wgFlaggedRevsStatsAge ); |
— | — | @@ -252,5 +263,5 @@ |
253 | 264 | } |
254 | 265 | echo "(sampled ".count($times)." edits)..."; |
255 | 266 | } |
256 | | - return array($aveRT,$medianRT,$rPerTable); |
| 267 | + return array($aveRT,$medianRT,$rPerTable,count($times)); |
257 | 268 | } |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php |
— | — | @@ -261,12 +261,12 @@ |
262 | 262 | |
263 | 263 | static $pcCounts = null; |
264 | 264 | if ( !$pcCounts ) { |
265 | | - $dbr = wfGetDB( DB_SLAVE ); |
266 | | - $res = $dbr->select( 'flaggedrevs_stats', '*', array(), __METHOD__ ); |
| 265 | + $stats = FlaggedRevsStats::getLatestStats(); |
| 266 | + $reviewedPerNS = $stats['reviewedPages-NS']; |
267 | 267 | $totalCount = 0; |
268 | | - foreach( $res as $row ) { |
269 | | - $nsList[ "ns-{$row->namespace}" ] = $row->reviewed; |
270 | | - $totalCount += $row->reviewed; |
| 268 | + foreach ( $reviewedPerNS as $ns => $reviewed ) { |
| 269 | + $nsList[ "ns-{$ns}" ] = $reviewed; |
| 270 | + $totalCount += $reviewed; |
271 | 271 | } |
272 | 272 | $nsList[ 'all' ] = $totalCount; |
273 | 273 | } |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevsStats.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * FlaggedRevs stats functions |
| 5 | + */ |
| 6 | +class FlaggedRevsStats { |
| 7 | + /* |
| 8 | + * Get latest FR-related stats |
| 9 | + * @return Array of current FR stats |
| 10 | + */ |
| 11 | + public static function getLatestStats() { |
| 12 | + $dbr = wfGetDB( DB_SLAVE ); |
| 13 | + $dbTs = $dbr->selectField( 'flaggedrevs_statistics', 'MAX(frs_timestamp)' ); |
| 14 | + $res = $dbr->select( 'flaggedrevs_statistics', |
| 15 | + array( 'frs_stat_key', 'frs_stat_val' ), |
| 16 | + array( 'frs_timestamp' => $dbTs ), |
| 17 | + __METHOD__ |
| 18 | + ); |
| 19 | + |
| 20 | + $data = array(); |
| 21 | + $data['reviewLag-sampleSize'] = '-'; |
| 22 | + $data['reviewLag-average'] = '-'; |
| 23 | + $data['reviewLag-median'] = '-'; |
| 24 | + $data['reviewLag-percentiles'] = array(); |
| 25 | + $data['totalPages-NS'] = array(); |
| 26 | + $data['reviewedPages-NS'] = array(); |
| 27 | + $data['syncedPages-NS'] = array(); |
| 28 | + $data['pendingLag-average'] = '-'; |
| 29 | + $data['statTimestamp'] = wfTimestamp( TS_MW, $dbTs ); |
| 30 | + |
| 31 | + foreach( $res as $row ) { |
| 32 | + $key = explode( ':', $row->frs_stat_key ); |
| 33 | + switch ( $key[0] ) { |
| 34 | + case 'reviewLag-sampleSize': |
| 35 | + case 'reviewLag-average': |
| 36 | + case 'reviewLag-median': |
| 37 | + case 'pendingLag-average': |
| 38 | + $data[$key[0]] = (int)$row->frs_stat_val; |
| 39 | + break; |
| 40 | + case 'reviewLag-percentile': // <stat name,percentile) |
| 41 | + $data[$key[0]][$key[1]] = (int)$row->frs_stat_val; |
| 42 | + break; |
| 43 | + case 'totalPages-NS': // <stat name,namespace) |
| 44 | + case 'reviewedPages-NS': // <stat name,namespace) |
| 45 | + case 'syncedPages-NS': // <stat name,namespace) |
| 46 | + $data[$key[0]][$key[1]] = (int)$row->frs_stat_val; |
| 47 | + break; |
| 48 | + } |
| 49 | + } |
| 50 | + return $data; |
| 51 | + } |
| 52 | +} |
Property changes on: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevsStats.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 53 | + native |
Index: trunk/extensions/FlaggedRevs/presentation/specialpages/reports/ValidationStatistics_body.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ValidationStatistics extends IncludableSpecialPage { |
| 5 | + protected $latestData = null; |
| 6 | + |
5 | 7 | public function __construct() { |
6 | 8 | parent::__construct( 'ValidationStatistics' ); |
7 | 9 | } |
— | — | @@ -18,6 +20,7 @@ |
19 | 21 | $mt = $this->getMeanReviewWait(); |
20 | 22 | $mdt = $this->getMedianReviewWait(); |
21 | 23 | $pt = $this->getMeanPendingWait(); |
| 24 | + $pData = $this->getPercentiles(); |
22 | 25 | $timestamp = $this->getLastUpdate(); |
23 | 26 | |
24 | 27 | $wgOut->addWikiMsg( 'validationstatistics-users', |
— | — | @@ -28,13 +31,10 @@ |
29 | 32 | return false; |
30 | 33 | } |
31 | 34 | |
32 | | - $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' ); |
33 | | - $dbCache = wfGetCache( CACHE_DB ); |
34 | | - $data = $dbCache->get( $key ); |
35 | 35 | # Is there a review time table available? |
36 | | - if ( is_array( $data ) && count( $data ) ) { |
| 36 | + if ( is_array( $pData ) && count( $pData ) ) { |
37 | 37 | $headerRows = $dataRows = ''; |
38 | | - foreach ( $data as $percentile => $perValue ) { |
| 38 | + foreach ( $pData as $percentile => $perValue ) { |
39 | 39 | $headerRows .= "<th>P<sub>" . intval( $percentile ) . "</sub></th>"; |
40 | 40 | $dataRows .= '<td>' . $wgLang->formatTimePeriod( $perValue ) . '</td>'; |
41 | 41 | } |
— | — | @@ -82,36 +82,39 @@ |
83 | 83 | $wgOut->addHTML( "</tr>\n" ); |
84 | 84 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
85 | 85 | foreach ( $namespaces as $namespace ) { |
86 | | - $row = $this->db->selectRow( 'flaggedrevs_stats', '*', |
87 | | - array( 'namespace' => $namespace ) ); |
88 | | - if( !$row ) continue; // NS added to config recently? |
| 86 | + $total = $this->getTotalPages( $namespace ); |
| 87 | + $reviewed = $this->getReviewedPages( $namespace ); |
| 88 | + $synced = $this->getSyncedPages( $namespace ); |
| 89 | + if ( $total === '-' || $reviewed === '-' || $synced === '-' ) { |
| 90 | + continue; // NS added to config recently? |
| 91 | + } |
89 | 92 | |
90 | | - $NsText = $wgContLang->getFormattedNsText( $row->namespace ); |
| 93 | + $NsText = $wgContLang->getFormattedNsText( $namespace ); |
91 | 94 | $NsText = $NsText ? $NsText : wfMsgHTML( 'blanknamespace' ); |
92 | 95 | |
93 | | - $percRev = intval( $row->total ) == 0 |
| 96 | + $percRev = intval( $total ) == 0 |
94 | 97 | ? '-' // devision by zero |
95 | 98 | : wfMsg( 'parentheses', |
96 | 99 | wfMsgExt( 'percent', array( 'escapenoentities' ), |
97 | 100 | $wgLang->formatnum( sprintf( '%4.2f', |
98 | | - 100 * intval( $row->reviewed ) / intval( $row->total ) ) ) |
| 101 | + 100 * intval( $reviewed ) / intval( $total ) ) ) |
99 | 102 | ) |
100 | 103 | ); |
101 | | - $percLatest = intval( $row->total ) == 0 |
| 104 | + $percLatest = intval( $total ) == 0 |
102 | 105 | ? '-' // devision by zero |
103 | 106 | : wfMsg( 'parentheses', |
104 | 107 | wfMsgExt( 'percent', array( 'escapenoentities' ), |
105 | 108 | $wgLang->formatnum( sprintf( '%4.2f', |
106 | | - 100 * intval( $row->synced ) / intval( $row->total ) ) ) |
| 109 | + 100 * intval( $synced ) / intval( $total ) ) ) |
107 | 110 | ) |
108 | 111 | ); |
109 | | - $percSynced = intval( $row->reviewed ) == 0 |
| 112 | + $percSynced = intval( $reviewed ) == 0 |
110 | 113 | ? '-' // devision by zero |
111 | 114 | : wfMsgExt( 'percent', array( 'escapenoentities' ), |
112 | 115 | $wgLang->formatnum( sprintf( '%4.2f', |
113 | | - 100 * intval( $row->synced ) / intval( $row->reviewed ) ) ) |
| 116 | + 100 * intval( $synced ) / intval( $reviewed ) ) ) |
114 | 117 | ); |
115 | | - $outdated = intval( $row->reviewed ) - intval( $row->synced ); |
| 118 | + $outdated = intval( $reviewed ) - intval( $synced ); |
116 | 119 | $outdated = $wgLang->formatnum( max( 0, $outdated ) ); // lag between queries |
117 | 120 | |
118 | 121 | $wgOut->addHTML( |
— | — | @@ -120,14 +123,14 @@ |
121 | 124 | htmlspecialchars( $NsText ) . |
122 | 125 | "</td> |
123 | 126 | <td>" . |
124 | | - htmlspecialchars( $wgLang->formatnum( $row->total ) ) . |
| 127 | + htmlspecialchars( $wgLang->formatnum( $total ) ) . |
125 | 128 | "</td> |
126 | 129 | <td>" . |
127 | | - htmlspecialchars( $wgLang->formatnum( $row->reviewed ) . |
| 130 | + htmlspecialchars( $wgLang->formatnum( $reviewed ) . |
128 | 131 | $wgContLang->getDirMark() ) . " <i>$percRev</i> |
129 | 132 | </td> |
130 | 133 | <td>" . |
131 | | - htmlspecialchars( $wgLang->formatnum( $row->synced ) . |
| 134 | + htmlspecialchars( $wgLang->formatnum( $synced ) . |
132 | 135 | $wgContLang->getDirMark() ) . " <i>$percLatest</i> |
133 | 136 | </td> |
134 | 137 | <td>" . |
— | — | @@ -193,10 +196,10 @@ |
194 | 197 | } |
195 | 198 | |
196 | 199 | protected function readyForQuery() { |
197 | | - if ( !$this->db->tableExists( 'flaggedrevs_stats' ) ) { |
| 200 | + if ( !$this->db->tableExists( 'flaggedrevs_statistics' ) ) { |
198 | 201 | return false; |
199 | 202 | } else { |
200 | | - return ( 0 != $this->db->selectField( 'flaggedrevs_stats', 'COUNT(*)' ) ); |
| 203 | + return ( 0 != $this->db->selectField( 'flaggedrevs_statistics', 'COUNT(*)' ) ); |
201 | 204 | } |
202 | 205 | } |
203 | 206 | |
— | — | @@ -211,30 +214,59 @@ |
212 | 215 | array( 'ug_group' => 'reviewer' ), |
213 | 216 | __METHOD__ ); |
214 | 217 | } |
215 | | - |
| 218 | + |
| 219 | + protected function getLatestStats() { |
| 220 | + if ( $this->latestData !== null ) { |
| 221 | + return $this->latestData; |
| 222 | + } |
| 223 | + $this->latestData = FlaggedRevsStats::getLatestStats(); |
| 224 | + return $this->latestData; |
| 225 | + } |
| 226 | + |
216 | 227 | protected function getMeanReviewWait() { |
217 | | - if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
218 | | - $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_review_time' ); |
219 | | - return ( $val == false ? '-' : $val ); |
| 228 | + $stats = $this->getLatestStats(); |
| 229 | + return $stats['reviewLag-average']; |
220 | 230 | } |
221 | 231 | |
222 | 232 | protected function getMedianReviewWait() { |
223 | | - if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
224 | | - $val = $this->db->selectField( 'flaggedrevs_stats2', 'med_review_time' ); |
225 | | - return ( $val == false ? '-' : $val ); |
| 233 | + $stats = $this->getLatestStats(); |
| 234 | + return $stats['reviewLag-median']; |
226 | 235 | } |
227 | 236 | |
228 | 237 | protected function getMeanPendingWait() { |
229 | | - if ( !$this->db->tableExists( 'flaggedrevs_stats2' ) ) return '-'; |
230 | | - $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_pending_time' ); |
231 | | - return ( $val == false ? '-' : $val ); |
| 238 | + $stats = $this->getLatestStats(); |
| 239 | + return $stats['pendingLag-average']; |
232 | 240 | } |
| 241 | + |
| 242 | + protected function getTotalPages( $ns ) { |
| 243 | + $stats = $this->getLatestStats(); |
| 244 | + return isset( $stats['totalPages-NS'][$ns] ) |
| 245 | + ? $stats['totalPages-NS'][$ns] |
| 246 | + : '-'; |
| 247 | + } |
233 | 248 | |
| 249 | + protected function getReviewedPages( $ns ) { |
| 250 | + $stats = $this->getLatestStats(); |
| 251 | + return isset( $stats['reviewedPages-NS'][$ns] ) |
| 252 | + ? $stats['reviewedPages-NS'][$ns] |
| 253 | + : '-'; |
| 254 | + } |
| 255 | + |
| 256 | + protected function getSyncedPages( $ns ) { |
| 257 | + $stats = $this->getLatestStats(); |
| 258 | + return isset( $stats['syncedPages-NS'][$ns] ) |
| 259 | + ? $stats['syncedPages-NS'][$ns] |
| 260 | + : '-'; |
| 261 | + } |
| 262 | + |
| 263 | + protected function getPercentiles() { |
| 264 | + $stats = $this->getLatestStats(); |
| 265 | + return $stats['reviewLag-percentile']; |
| 266 | + } |
| 267 | + |
234 | 268 | protected function getLastUpdate() { |
235 | | - if ( !$this->db->tableExists( 'querycache_info' ) ) return '-'; |
236 | | - $val = $this->db->selectField( 'querycache_info', 'qci_timestamp', |
237 | | - array( 'qci_type' => 'validationstats' ) ); |
238 | | - return ( $val == false ? '-' : $val ); |
| 269 | + $stats = $this->getLatestStats(); |
| 270 | + return $stats['statTimestamp']; |
239 | 271 | } |
240 | 272 | |
241 | 273 | // top X reviewers in the last Y hours |