Index: trunk/extensions/ReaderFeedback/specialpages/RatedPages_body.php |
— | — | @@ -25,11 +25,16 @@ |
26 | 26 | if( wfReadOnly() ) { |
27 | 27 | return $wgOut->readOnlyPage(); |
28 | 28 | } |
| 29 | + // Purge expired entries on one in every 10 queries |
| 30 | + if( 0 == mt_rand( 0, 10 ) ) { |
| 31 | + ReaderFeedback::purgeExpiredAverages(); |
| 32 | + } |
29 | 33 | $this->skin = $wgUser->getSkin(); |
30 | 34 | # Check if there is a featured level |
31 | 35 | $this->namespace = $wgRequest->getInt( 'namespace' ); |
32 | 36 | $this->tag = $wgRequest->getVal( 'ratingtag' ); |
33 | 37 | $this->tier = $wgRequest->getInt( 'ratingtier' ); |
| 38 | + |
34 | 39 | $this->showForm(); |
35 | 40 | $this->showPageList(); |
36 | 41 | } |
Index: trunk/extensions/ReaderFeedback/specialpages/ReaderFeedback_body.php |
— | — | @@ -341,6 +341,10 @@ |
342 | 342 | if( $wgUser->getId() ) { |
343 | 343 | $this->page->invalidateCache(); |
344 | 344 | } |
| 345 | + # Prune expired page aggregate data |
| 346 | + if( 0 == mt_rand( 0, 99 ) ) { |
| 347 | + ReaderFeedback::purgeExpiredAverages(); |
| 348 | + } |
345 | 349 | return self::REVIEW_OK; |
346 | 350 | } |
347 | 351 | } |
Index: trunk/extensions/ReaderFeedback/ReaderFeedback.class.php |
— | — | @@ -101,6 +101,18 @@ |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
| 105 | + * Purge outdated page average data |
| 106 | + * @returns bool |
| 107 | + */ |
| 108 | + public static function purgeExpiredAverages() { |
| 109 | + global $wgFeedbackAge; |
| 110 | + $dbw = wfGetDB( DB_MASTER ); |
| 111 | + $cutoff = $dbw->addQuotes( $dbw->timestamp( time() - $wgFeedbackAge ) ); |
| 112 | + $dbw->delete( 'reader_feedback_pages', array("rfp_touched < $cutoff"), __METHOD__ ); |
| 113 | + return ( $dbw->affectedRows() != 0 ); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
105 | 117 | * Is this page in rateable namespace? |
106 | 118 | * @param Title, $title |
107 | 119 | * @return bool |