[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Split some long lines in SparqlHelper
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/385958 ) Change subject: Split some long lines in SparqlHelper .. Split some long lines in SparqlHelper They could also be shortened by extracting the common prefix into a variable, but then it would no longer be possible to search for the full key in the code. Change-Id: I1c1982cdbe83b90fd2b14cf95048f473a0c98dc2 --- M includes/ConstraintCheck/Helper/SparqlHelper.php 1 file changed, 12 insertions(+), 6 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/ConstraintCheck/Helper/SparqlHelper.php b/includes/ConstraintCheck/Helper/SparqlHelper.php index cd1be46..89680c8 100644 --- a/includes/ConstraintCheck/Helper/SparqlHelper.php +++ b/includes/ConstraintCheck/Helper/SparqlHelper.php @@ -349,17 +349,21 @@ function( $cacheMapArray ) use ( $text, $regex, $textHash, $cacheMapSize ) { // Initialize the cache map if not set if ( $cacheMapArray === false ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.init' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.init'; + $this->dataFactory->increment( $key ); return []; } - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh'; + $this->dataFactory->increment( $key ); $cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $cacheMapSize ); if ( $cacheMap->has( $textHash ) ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.hit' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.hit'; + $this->dataFactory->increment( $key ); $cacheMap->get( $textHash ); // ping cache } else { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.miss' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.miss'; + $this->dataFactory->increment( $key ); $cacheMap->set( $textHash, $this->matchesRegularExpressionWithSparql( $text, $regex ), @@ -382,10 +386,12 @@ ); if ( isset( $cacheMapArray[$textHash] ) ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.hit' ); + $key = 'wikibase.quality.constraints.regex.cache.hit'; + $this->dataFactory->increment( $key ); return $cacheMapArray[$textHash]; } else { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.miss' ); + $key = 'wikibase.quality.constraints.regex.cache.miss'; + $this->dataFactory->increment( $key ); return $this->matchesRegularExpressionWithSparql( $text, $regex ); } } -- To view, visit https://gerrit.wikimedia.org/r/385958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1c1982cdbe83b90fd2b14cf95048f473a0c98dc2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) Gerrit-Reviewer: Aaron Schulz Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Split some long lines in SparqlHelper
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/385958 ) Change subject: Split some long lines in SparqlHelper .. Split some long lines in SparqlHelper They could also be shortened by extracting the common prefix into a variable, but then it would no longer be possible to search for the full key in the code. Change-Id: I1c1982cdbe83b90fd2b14cf95048f473a0c98dc2 --- M includes/ConstraintCheck/Helper/SparqlHelper.php 1 file changed, 12 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints refs/changes/58/385958/1 diff --git a/includes/ConstraintCheck/Helper/SparqlHelper.php b/includes/ConstraintCheck/Helper/SparqlHelper.php index cd1be46..89680c8 100644 --- a/includes/ConstraintCheck/Helper/SparqlHelper.php +++ b/includes/ConstraintCheck/Helper/SparqlHelper.php @@ -349,17 +349,21 @@ function( $cacheMapArray ) use ( $text, $regex, $textHash, $cacheMapSize ) { // Initialize the cache map if not set if ( $cacheMapArray === false ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.init' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.init'; + $this->dataFactory->increment( $key ); return []; } - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh'; + $this->dataFactory->increment( $key ); $cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $cacheMapSize ); if ( $cacheMap->has( $textHash ) ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.hit' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.hit'; + $this->dataFactory->increment( $key ); $cacheMap->get( $textHash ); // ping cache } else { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.refresh.miss' ); + $key = 'wikibase.quality.constraints.regex.cache.refresh.miss'; + $this->dataFactory->increment( $key ); $cacheMap->set( $textHash, $this->matchesRegularExpressionWithSparql( $text, $regex ), @@ -382,10 +386,12 @@ ); if ( isset( $cacheMapArray[$textHash] ) ) { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.hit' ); + $key = 'wikibase.quality.constraints.regex.cache.hit'; + $this->dataFactory->increment( $key ); return $cacheMapArray[$textHash]; } else { - $this->dataFactory->increment( 'wikibase.quality.constraints.regex.cache.miss' ); + $key = 'wikibase.quality.constraints.regex.cache.miss'; + $this->dataFactory->increment( $key ); return $this->matchesRegularExpressionWithSparql( $text, $regex ); } } -- To view, visit https://gerrit.wikimedia.org/r/385958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c1982cdbe83b90fd2b14cf95048f473a0c98dc2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits