jenkins-bot has submitted this change and it was merged.
Change subject: Improve type hints in EvaluateConstraintReportJobService
......................................................................
Improve type hints in EvaluateConstraintReportJobService
Change-Id: I883c0882745cd628d4ce7eaf647c8d78b261ab29
---
M includes/EvaluateConstraintReportJobService.php
1 file changed, 12 insertions(+), 10 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/EvaluateConstraintReportJobService.php
b/includes/EvaluateConstraintReportJobService.php
index 8857ade..4f6106e 100644
--- a/includes/EvaluateConstraintReportJobService.php
+++ b/includes/EvaluateConstraintReportJobService.php
@@ -7,7 +7,6 @@
use Wikibase\Repo\WikibaseRepo;
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
-
/**
* Class EvaluateConstraintReportJobService
*
@@ -45,16 +44,17 @@
}
/**
- * @param $results
+ * @param CheckResult[] $results
*
* @return string
*/
- public function buildResultSummary( $results ) {
+ public function buildResultSummary( array $results ) {
$summary = array();
foreach ( $results as $result ) {
$constraintName = $result->getConstraintName();
$status = $result->getStatus();
+
if( !array_key_exists( $constraintName, $summary ) ) {
$summary[$constraintName] = array(
CheckResult::STATUS_COMPLIANCE => 0,
@@ -63,6 +63,7 @@
CheckResult::STATUS_TODO => 0
);
}
+
if( array_key_exists( $status,
$summary[$constraintName] ) ) {
$summary[$constraintName][$status]++;
}
@@ -81,14 +82,15 @@
* @return string
*/
public function getResults( $params ) {
- if ( !array_key_exists( 'results', $params ) ) {
- $lookup =
WikibaseRepo::getDefaultInstance()->getEntityLookup();
- $constraintChecker =
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker();
- $entityId = $params['entityId'][0] === 'Q' ? new
ItemId( $params['entityId'] ) : new PropertyId( $params['entityId'] );
- $results = $constraintChecker->checkAgainstConstraints(
$lookup->getEntity( $entityId ) );
- return $this->buildResultSummary( $results );
- } else {
+ if ( array_key_exists( 'results', $params ) ) {
return $params['results'];
}
+
+ $lookup = WikibaseRepo::getDefaultInstance()->getEntityLookup();
+ $constraintChecker =
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker();
+ $entityId = $params['entityId'][0] === 'Q' ? new ItemId(
$params['entityId'] ) : new PropertyId( $params['entityId'] );
+ $results = $constraintChecker->checkAgainstConstraints(
$lookup->getEntity( $entityId ) );
+
+ return $this->buildResultSummary( $results );
}
}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/229642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I883c0882745cd628d4ce7eaf647c8d78b261ab29
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits