r58041 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58040‎ | r58041 | r58042 >
Date:22:12, 22 October 2009
Author:aaron
Status:ok
Tags:
Comment:
Purge de-normalized expired page average data
Modified paths:
  • /trunk/extensions/ReaderFeedback/ReaderFeedback.class.php (modified) (history)
  • /trunk/extensions/ReaderFeedback/specialpages/RatedPages_body.php (modified) (history)
  • /trunk/extensions/ReaderFeedback/specialpages/ReaderFeedback_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReaderFeedback/specialpages/RatedPages_body.php
@@ -25,11 +25,16 @@
2626 if( wfReadOnly() ) {
2727 return $wgOut->readOnlyPage();
2828 }
 29+ // Purge expired entries on one in every 10 queries
 30+ if( 0 == mt_rand( 0, 10 ) ) {
 31+ ReaderFeedback::purgeExpiredAverages();
 32+ }
2933 $this->skin = $wgUser->getSkin();
3034 # Check if there is a featured level
3135 $this->namespace = $wgRequest->getInt( 'namespace' );
3236 $this->tag = $wgRequest->getVal( 'ratingtag' );
3337 $this->tier = $wgRequest->getInt( 'ratingtier' );
 38+
3439 $this->showForm();
3540 $this->showPageList();
3641 }
Index: trunk/extensions/ReaderFeedback/specialpages/ReaderFeedback_body.php
@@ -341,6 +341,10 @@
342342 if( $wgUser->getId() ) {
343343 $this->page->invalidateCache();
344344 }
 345+ # Prune expired page aggregate data
 346+ if( 0 == mt_rand( 0, 99 ) ) {
 347+ ReaderFeedback::purgeExpiredAverages();
 348+ }
345349 return self::REVIEW_OK;
346350 }
347351 }
Index: trunk/extensions/ReaderFeedback/ReaderFeedback.class.php
@@ -101,6 +101,18 @@
102102 }
103103
104104 /**
 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+ /**
105117 * Is this page in rateable namespace?
106118 * @param Title, $title
107119 * @return bool

Status & tagging log