Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevsStats.php |
— | — | @@ -303,27 +303,34 @@ |
304 | 304 | # For edits that started off pending, how long do they take to get reviewed? |
305 | 305 | # Edits started off pending if made when a flagged rev of the page already existed. |
306 | 306 | # Get the *first* reviewed rev *after* each edit and get the time difference. |
307 | | - list( $revision, $flaggedrevs ) = $dbr->tableNamesN( 'revision', 'flaggedrevs' ); |
308 | | - $sql = " |
309 | | - SELECT |
310 | | - MIN(rev_timestamp) AS rt, MIN(n.fr_timestamp) AS nft, MAX(p.fr_rev_id) |
311 | | - FROM $revision |
312 | | - INNER JOIN $flaggedrevs AS p FORCE INDEX (PRIMARY) ON |
313 | | - (p.fr_page_id = rev_page AND p.fr_rev_id < rev_id AND p.fr_timestamp < rev_timestamp) |
314 | | - INNER JOIN $flaggedrevs AS n FORCE INDEX (PRIMARY) ON |
315 | | - (n.fr_page_id = rev_page AND n.fr_rev_id >= rev_id AND n.fr_timestamp >= rev_timestamp) |
316 | | - WHERE |
317 | | - ((rev_user = 0) AND ($timeCondition) AND ((rev_id % $mod) = 0)) |
318 | | - GROUP BY rev_id"; |
319 | | - # Actually run the query... |
320 | | - $res = $dbr->query( $sql, __METHOD__ ); |
| 307 | + $res = $dbr->select( |
| 308 | + array( 'revision', 'p' => 'flaggedrevs', 'n' => 'flaggedrevs' ), |
| 309 | + array( 'MIN(rev_timestamp) AS rt', 'MIN(n.fr_timestamp) AS nft', 'MAX(p.fr_rev_id)' ), |
| 310 | + array( 'rev_user' => 0, $timeCondition, "(rev_id % $mod) = 0" ), |
| 311 | + __METHOD__, |
| 312 | + array( |
| 313 | + 'GROUP BY' => 'rev_id', |
| 314 | + 'USE INDEX' => array( 'p' => 'PRIMARY', 'n' => 'PRIMARY' ) |
| 315 | + ), |
| 316 | + array( |
| 317 | + 'p' => array( 'INNER JOIN', array( // last review |
| 318 | + 'p.fr_page_id = rev_page', |
| 319 | + 'p.fr_rev_id < rev_id', |
| 320 | + 'p.fr_timestamp < rev_timestamp' ) ), |
| 321 | + 'n' => array( 'INNER JOIN', array( // next review |
| 322 | + 'n.fr_page_id = rev_page', |
| 323 | + 'n.fr_rev_id >= rev_id', |
| 324 | + 'n.fr_timestamp >= rev_timestamp' ) ) |
| 325 | + ) |
| 326 | + ); |
| 327 | + |
321 | 328 | $secondsR = 0; // total wait seconds for edits later reviewed |
322 | 329 | $secondsP = 0; // total wait seconds for edits still pending |
323 | 330 | $aveRT = $medianRT = 0; |
324 | 331 | if ( $dbr->numRows( $res ) ) { |
325 | 332 | $times = array(); |
326 | 333 | # Get the elapsed times revs were pending (flagged time - edit time) |
327 | | - foreach( $res as $row ) { |
| 334 | + foreach ( $res as $row ) { |
328 | 335 | $time = wfTimestamp(TS_UNIX,$row->nft) - wfTimestamp(TS_UNIX,$row->rt); |
329 | 336 | $time = max( $time, 0 ); // sanity |
330 | 337 | $secondsR += $time; |