Avoid showing crazy staleness times at ActiveUsers
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 25 Feb 2014 22:38:09 +0000 (14:38 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 28 Feb 2014 23:28:27 +0000 (15:28 -0800)
* Also do the query more aggressively on small wikis

Change-Id: I089b2f69d03bb289035be11ccfe4937931904d25

includes/specials/SpecialActiveusers.php

index 641c046..1fed516 100644 (file)
@@ -242,7 +242,7 @@ class SpecialActiveUsers extends SpecialPage {
                        array( 'activeusers-intro', $this->getLanguage()->formatNum( $wgActiveUserDays ) ) );
 
                // Occasionally merge in new updates
-               $seconds = self::mergeActiveUsers( 600 );
+               $seconds = min( self::mergeActiveUsers( 600 ), $wgActiveUserDays * 86400 );
                // Mention the level of staleness
                $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
                        $this->getLanguage()->formatDuration( $seconds ) );
@@ -283,7 +283,12 @@ class SpecialActiveUsers extends SpecialPage {
                if ( !wfReadOnly() ) {
                        if ( !$cTime || ( time() - wfTimestamp( TS_UNIX, $cTime ) ) > $period ) {
                                $dbw = wfGetDB( DB_MASTER );
-                               self::doQueryCacheUpdate( $dbw, 2 * $period );
+                               if ( $dbw->estimateRowCount( 'recentchanges' ) <= 10000 ) {
+                                       $window = $wgActiveUserDays * 86400; // small wiki
+                               } else {
+                                       $window = $period * 2;
+                               }
+                               self::doQueryCacheUpdate( $dbw, $window );
                        }
                }
                return ( time() -