Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php |
— | — | @@ -200,16 +200,9 @@ |
201 | 201 | } |
202 | 202 | // Define the data using the DB rows |
203 | 203 | $totalVal = $totalCount = $n = 0; |
204 | | - list($res,$u,$maxC) = $this->doQuery( $tag ); |
| 204 | + list($res,$u,$maxC,$days) = $this->doQuery( $tag ); |
205 | 205 | // Label spacing |
206 | | - if( $row = $res->fetchObject() ) { |
207 | | - $lower = wfTimestamp( TS_UNIX, $row->rfh_date ); |
208 | | - $res->seek( $res->numRows()-1 ); |
209 | | - $upper = wfTimestamp( TS_UNIX, $res->fetchObject( $res )->rfh_date ); |
210 | | - $days = intval( ($upper - $lower)/86400 ); |
211 | | - $int = intval( ceil($days/10) ); // 10 labels at most |
212 | | - $res->seek( 0 ); |
213 | | - } |
| 206 | + $int = intval( ceil($days/10) ); // 10 labels at most |
214 | 207 | $dates = $drating = $arating = $dcount = ""; |
215 | 208 | while( $row = $res->fetchObject() ) { |
216 | 209 | $totalVal += (int)$row->rfh_total; |
— | — | @@ -267,16 +260,9 @@ |
268 | 261 | $data = array(); |
269 | 262 | $totalVal = $totalCount = $n = 0; |
270 | 263 | // Define the data using the DB rows |
271 | | - list($res,$u,$maxC) = $this->doQuery( $tag ); |
| 264 | + list($res,$u,$maxC,$days) = $this->doQuery( $tag ); |
272 | 265 | // Label spacing |
273 | | - if( $row = $res->fetchObject() ) { |
274 | | - $lower = wfTimestamp( TS_UNIX, $row->rfh_date ); |
275 | | - $res->seek( $res->numRows()-1 ); |
276 | | - $upper = wfTimestamp( TS_UNIX, $res->fetchObject()->rfh_date ); |
277 | | - $days = intval( ($upper - $lower)/86400 ); |
278 | | - $int = ($days > 31) ? 31 : intval( ceil($days/12) ); |
279 | | - $res->seek( 0 ); |
280 | | - } |
| 266 | + $int = intval( ceil($days/10) ); // 10 labels at most |
281 | 267 | while( $row = $res->fetchObject() ) { |
282 | 268 | $totalVal += (int)$row->rfh_total; |
283 | 269 | $totalCount += (int)$row->rfh_count; |
— | — | @@ -373,16 +359,9 @@ |
374 | 360 | $dataX = $dave = $rave = $dcount = array(); |
375 | 361 | $totalVal = $totalCount = $sd = $pts = $n = 0; |
376 | 362 | // Define the data using the DB rows |
377 | | - list($res,$u,$maxC) = $this->doQuery( $tag ); |
| 363 | + list($res,$u,$maxC,$days) = $this->doQuery( $tag ); |
378 | 364 | // Label spacing |
379 | | - if( $row = $res->fetchObject() ) { |
380 | | - $lower = wfTimestamp( TS_UNIX, $row->rfh_date ); |
381 | | - $res->seek( $res->numRows()-1 ); |
382 | | - $upper = wfTimestamp( TS_UNIX, $res->fetchObject()->rfh_date ); |
383 | | - $days = intval( ($upper - $lower)/86400 ); |
384 | | - $int = ($days > 31) ? 31 : ceil($days/12); |
385 | | - $res->seek( 0 ); |
386 | | - } |
| 365 | + $int = intval( ceil($days/10) ); // 10 labels at most |
387 | 366 | while( $row = $res->fetchObject() ) { |
388 | 367 | $pts++; |
389 | 368 | $totalVal += (int)$row->rfh_total; |
— | — | @@ -500,17 +479,23 @@ |
501 | 480 | array( 'ORDER BY' => 'rfh_date ASC' ) |
502 | 481 | ); |
503 | 482 | # Get max count and average rating |
504 | | - $total = $count = $ave = $maxC = 0; |
505 | | - if( $dbr->numRows($res) ) { |
| 483 | + $total = $count = $ave = $maxC = $days = 0; |
| 484 | + if( $dbr->numRows($res) > 0 ) { |
506 | 485 | while( $row = $dbr->fetchObject($res) ) { |
| 486 | + if( !isset($lower) ) { |
| 487 | + $lower = wfTimestamp( TS_UNIX, $row->rfh_date ); // first day |
| 488 | + } |
507 | 489 | $total += (int)$row->rfh_total; |
508 | 490 | $count += (int)$row->rfh_count; |
509 | 491 | if( $row->rfh_count > $maxC ) $maxC = intval($row->rfh_count); |
| 492 | + $upper = $row->rfh_date; |
510 | 493 | } |
511 | | - $ave = 1+$total/$count; // Offset to [1,5] |
512 | | - $res->seek( 0 ); |
| 494 | + $upper = wfTimestamp( TS_UNIX, $upper ); |
| 495 | + $days = intval( ($upper - $lower)/86400 ); |
| 496 | + $ave = 1 + $total/$count; // Offset to [1,5] |
| 497 | + $res->seek( 0 ); // reset query row |
513 | 498 | } |
514 | | - return array($res,$ave,$maxC); |
| 499 | + return array($res,$ave,$maxC,$days); |
515 | 500 | } |
516 | 501 | |
517 | 502 | /** |