jenkins-bot has submitted this change and it was merged. Change subject: Clean up DispatchStats class ......................................................................
Clean up DispatchStats class E.g. private by default, drop superfluous private properties and so on. Change-Id: I8f27fdefe01d92a12475bae44d32a2085b44def9 --- M repo/includes/store/sql/DispatchStats.php 1 file changed, 18 insertions(+), 43 deletions(-) Approvals: Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/store/sql/DispatchStats.php b/repo/includes/store/sql/DispatchStats.php index b3db135..4e893d8 100644 --- a/repo/includes/store/sql/DispatchStats.php +++ b/repo/includes/store/sql/DispatchStats.php @@ -1,8 +1,10 @@ <?php + namespace Wikibase; /** * Utility class for collecting dispatch statistics. + * Note that you must call load() before accessing any getters. * * @since 0.4 * @@ -12,44 +14,19 @@ class DispatchStats { /** - * @var string + * @var object[]|null */ - protected $dispatchTableName; + private $clientStates = null; /** - * @var string + * @var object|null */ - protected $changesTableName; + private $changeStats = null; /** - * @var null|array + * @var object|null */ - protected $clientStates; - - /** - * @var null|object - */ - protected $changeStats; - - /** - * @var null|object - */ - protected $average; - - /** - * creates a new DispatchStats instance. - * - * Call load() before accessing any getters. - */ - public function __construct() { - $this->dispatchTableName = 'wb_changes_dispatch'; - $this->changesTableName = 'wb_changes'; - - $this->clientStates = null; - $this->changeStats = null; - - $this->average = null; - } + private $average = null; /** * Loads the current dispatch status from the database and calculates statistics. @@ -65,7 +42,7 @@ $now = wfTimestamp( TS_UNIX, $now ); $this->changeStats = $db->selectRow( - $this->changesTableName, + 'wb_changes', array( 'min( change_id ) as min_id', 'max( change_id ) as max_id', @@ -78,8 +55,8 @@ $res = $db->select( array ( - $this->dispatchTableName, - $this->changesTableName + 'wb_changes_dispatch', + 'wb_changes' ), array( 'chd_site', 'chd_db', @@ -97,7 +74,7 @@ 'ORDER BY' => 'chd_seen ASC' ), array( - $this->changesTableName => array( 'LEFT JOIN', 'chd_seen = change_id' ) + 'wb_changes' => array( 'LEFT JOIN', 'chd_seen = change_id' ) ) ); @@ -108,7 +85,7 @@ $this->clientStates = array(); - while ( $row = $res->fetchObject() ) { + while ( ( $row = $res->fetchObject() ) !== false ) { if ( $this->changeStats ) { // time between last dispatch and now $row->chd_untouched = max( 0, $now @@ -176,7 +153,7 @@ * determined, but the lag is large. * * chd_lock: the name of the lock currently in effect for that wiki * - * @return array|null A list of objects representing the dispatch state + * @return object[]|null A list of objects representing the dispatch state * for each client wiki. */ public function getClientStates() { @@ -216,23 +193,22 @@ return reset( $this->clientStates ); } - /** * Returns a dispatch status object for the client wiki * that represents the median in terms of dispatch lag. * * See getClientStates() for the structure of the status object. * - * @return object + * @return object|null */ public function getMedian() { - $n = $this->getClientCount(); + $count = $this->getClientCount(); - if ( $n == 0 ) { + if ( $count <= 0 ) { return null; } - $i = (int)floor( $n / 2 ); + $i = (int)( $count / 2 ); return $this->clientStates[$i]; } @@ -308,4 +284,3 @@ } } - -- To view, visit https://gerrit.wikimedia.org/r/207441 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8f27fdefe01d92a12475bae44d32a2085b44def9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits