Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/237430

Change subject: Remove evaluationCrossCheckJob - no longer needed
......................................................................

Remove evaluationCrossCheckJob - no longer needed

Bug: T112090
Change-Id: I98d0d471fdd24c749b44dae70082e2d59cc61c0e
---
M WikibaseQualityExternalValidation.php
D includes/EvaluateCrossCheckJob.php
D includes/EvaluateCrossCheckJobService.php
M specials/SpecialCrossCheck.php
D tests/phpunit/EvaluateCrossCheckJobServiceTest.php
M tests/phpunit/Specials/SpecialCrossCheckTest.php
6 files changed, 1 insertion(+), 305 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityExternalValidation
 refs/changes/30/237430/1

diff --git a/WikibaseQualityExternalValidation.php 
b/WikibaseQualityExternalValidation.php
index 8366026..091e2e7 100755
--- a/WikibaseQualityExternalValidation.php
+++ b/WikibaseQualityExternalValidation.php
@@ -43,9 +43,6 @@
                'remoteExtPath' => 'WikibaseQualityExternalValidation'
        );
 
-       // Jobs
-       $GLOBALS['wgJobClasses']['evaluateCrossCheckJob'] = 
'WikibaseQuality\ExternalValidation\EvaluateCrossCheckJob';
-
        // Ids of certain Wikidata entities
        if( !defined( 'INSTANCE_OF_PID' ) ) {
                define( 'INSTANCE_OF_PID', 'P31' );
diff --git a/includes/EvaluateCrossCheckJob.php 
b/includes/EvaluateCrossCheckJob.php
deleted file mode 100755
index f5ad3f9..0000000
--- a/includes/EvaluateCrossCheckJob.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-
-namespace WikibaseQuality\ExternalValidation;
-
-use Job;
-use Title;
-
-/**
- * Class EvaluateCrossCheckJob
- *
- * @package WikibaseQuality\ExternalValidation
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class EvaluateCrossCheckJob extends Job {
-
-       /**
-        * @var EvaluateCrossCheckJobService
-        */
-       private $service;
-
-       /**
-        * @param string $entityId
-        * @param int $checkTimestamp
-        * @param string $results
-        *
-        * @return EvaluateCrossCheckJob
-        * @throws \MWException
-        */
-       public static function newInsertNow( $entityId, $checkTimestamp, 
$results ) {
-               // The Job class wants a Title object for some reason. Supply a 
dummy.
-               $dummyTitle = Title::newFromText( "EvaluateCrossCheckJob", 
NS_SPECIAL );
-
-               $params = array();
-
-               $params['entityId'] = $entityId;
-               $params['results'] = $results;
-               $params['checkTimestamp'] = $checkTimestamp;
-               $params['referenceTimestamp'] = null;
-
-               return new EvaluateCrossCheckJob( $dummyTitle, $params );
-       }
-
-       /**
-        * @param string $entityId
-        * @param int|null $referenceTimestamp
-        * @param int $delay
-        *
-        * @return EvaluateCrossCheckJob
-        * @throws \MWException
-        */
-       public static function newInsertDeferred( $entityId, 
$referenceTimestamp = null, $delay = 0 ) {
-               // The Job class wants a Title object for some reason. Supply a 
dummy.
-               $dummyTitle = Title::newFromText( "EvaluateCrossCheckJob", 
NS_SPECIAL );
-
-               $params = array();
-
-               $params['entityId'] = $entityId;
-               $params['results'] = null;
-               $params['referenceTimestamp'] = $referenceTimestamp;
-               $params['jobReleaseTimestamp'] = wfTimestamp( TS_UNIX ) + 
$delay;
-
-               return new EvaluateCrossCheckJob( $dummyTitle, $params );
-       }
-
-       /**
-        * @param Title $title
-        * @param array $params - array with keys entityId, results, 
referenceTimestamp, jobReleaseTimestamp
-        */
-       public function __construct( Title $title, $params ) {
-               parent::__construct( 'evaluateCrossCheckJob', $title, $params );
-               $this->service = new EvaluateCrossCheckJobService();
-       }
-
-       public function run() {
-               $checkTimestamp = array_key_exists( 'checkTimestamp', 
$this->params ) ? $this->params['checkTimestamp'] : wfTimestamp( TS_UNIX );
-
-               $resultSummary = $this->service->getResults( $this->params );
-               $messageToLog = $this->service->buildMessageForLog( 
$resultSummary, $checkTimestamp, $this->params );
-               $this->service->writeToLog( $messageToLog );
-
-       }
-
-}
\ No newline at end of file
diff --git a/includes/EvaluateCrossCheckJobService.php 
b/includes/EvaluateCrossCheckJobService.php
deleted file mode 100755
index b095f5a..0000000
--- a/includes/EvaluateCrossCheckJobService.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-namespace WikibaseQuality\ExternalValidation;
-
-use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\PropertyId;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\ComparisonResult;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\ReferenceResult;
-
-/**
- * Class EvaluateCrossCheckJobService
- *
- * @package WikibaseQuality\ExternalValidation
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class EvaluateCrossCheckJobService {
-
-       public function writeToLog( $message ) {
-               wfDebugLog( 'wbq_evaluation', $message );
-       }
-
-       public function buildMessageForLog( $resultSummary, $timestamp, $params 
) {
-               return json_encode(
-                       array(
-                               'special_page_id' => 'SpecialCrossCheck',
-                               'entity_id' => $params['entityId'],
-                               'insertion_timestamp' => $timestamp,
-                               'reference_timestamp' => 
$params['referenceTimestamp'],
-                               'result_summary' => $resultSummary
-                       )
-               );
-       }
-
-       public function buildResultSummary( $results ) {
-               $summary = array(
-                       'Matches with reference' => 0,
-                       'Matches without reference' => 0,
-                       'Partial matches with reference' => 0,
-                       'Partial matches without reference' => 0,
-                       'Mismatches with reference' => 0,
-                       'Mismatches without reference' => 0,
-               );
-               foreach ( $results as $result ) {
-                       $comparisonResult = 
$result->getComparisonResult()->getStatus();
-                       $referenceResult = 
$result->getReferenceResult()->getStatus();
-                       if ( $referenceResult === 
ReferenceResult::STATUS_REFERENCES_MISSING ) {
-                               switch ( $comparisonResult ) {
-                                       case ComparisonResult::STATUS_MATCH:
-                                               $summary['Matches without 
reference']++;
-                                               break;
-                                       case 
ComparisonResult::STATUS_PARTIAL_MATCH:
-                                               $summary['Partial matches 
without reference']++;
-                                               break;
-                                       case ComparisonResult::STATUS_MISMATCH:
-                                               $summary['Mismatches without 
reference']++;
-                               }
-                       } elseif ( $referenceResult === 
ReferenceResult::STATUS_REFERENCES_STATED ) {
-                               switch ( $comparisonResult ) {
-                                       case ComparisonResult::STATUS_MATCH:
-                                               $summary['Matches with 
reference']++;
-                                               break;
-                                       case 
ComparisonResult::STATUS_PARTIAL_MATCH:
-                                               $summary['Partial matches with 
reference']++;
-                                               break;
-                                       case ComparisonResult::STATUS_MISMATCH:
-                                               $summary['Mismatches with 
reference']++;
-                               }
-                       }
-
-               }
-
-               return json_encode( $summary );
-       }
-
-       public function getResults( $params ) {
-               if ( !array_key_exists( 'results', $params ) ) {
-                       $crossChecker = 
ExternalValidationServices::getDefaultInstance()->getCrossCheckInteractor();
-                       $entityId = $params['entityId'][0] === 'Q' ? new 
ItemId( $params['entityId'] ) : new PropertyId( $params['entityId'] );
-                       $results = $crossChecker->crossCheckEntityById( 
$entityId );
-                       return $this->buildResultSummary( $results );
-               } else {
-                       return $params['results'];
-               }
-       }
-
-}
\ No newline at end of file
diff --git a/specials/SpecialCrossCheck.php b/specials/SpecialCrossCheck.php
index d0f9a43..5649486 100755
--- a/specials/SpecialCrossCheck.php
+++ b/specials/SpecialCrossCheck.php
@@ -29,8 +29,6 @@
 use Wikibase\Repo\WikibaseRepo;
 use WikibaseQuality\ExternalValidation\CrossCheck\CrossCheckInteractor;
 use WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList;
-use WikibaseQuality\ExternalValidation\EvaluateCrossCheckJob;
-use WikibaseQuality\ExternalValidation\EvaluateCrossCheckJobService;
 use WikibaseQuality\ExternalValidation\ExternalValidationServices;
 use WikibaseQuality\Html\HtmlTableBuilder;
 use WikibaseQuality\Html\HtmlTableCellBuilder;
@@ -190,10 +188,6 @@
                        }
 
                        $results = 
$this->crossCheckInteractor->crossCheckEntity( $entity );
-
-                       if (!defined('MW_PHPUNIT_TEST')) {
-                               $this->doEvaluation($entity, $results);
-                       }
 
                        if ($results && count($results) > 0) {
                                $out->addHTML(
@@ -461,18 +455,4 @@
                return $table->toHtml();
        }
 
-       private function doEvaluation($entity, $results)
-       {
-               if ( $this->getUser()->pingLimiter( 'pushJob' ) ){
-                       return;
-               }
-               $checkTimeStamp = wfTimestamp(TS_UNIX);
-               $service = new EvaluateCrossCheckJobService();
-               $results = $service->buildResultSummary($results);
-               $jobs = array();
-               $jobs[] = 
EvaluateCrossCheckJob::newInsertNow($entity->getId()->getSerialization(), 
$checkTimeStamp, $results);
-               $jobs[] = 
EvaluateCrossCheckJob::newInsertDeferred($entity->getId()->getSerialization(), 
$checkTimeStamp, 10 * 60);
-               $jobs[] = 
EvaluateCrossCheckJob::newInsertDeferred($entity->getId()->getSerialization(), 
$checkTimeStamp, 60 * 60);
-               JobQueueGroup::singleton()->push( $jobs );
-       }
 }
diff --git a/tests/phpunit/EvaluateCrossCheckJobServiceTest.php 
b/tests/phpunit/EvaluateCrossCheckJobServiceTest.php
deleted file mode 100755
index 5986314..0000000
--- a/tests/phpunit/EvaluateCrossCheckJobServiceTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-namespace WikibaseQuality\ExternalValidation\Tests;
-
-use DataValues\StringValue;
-use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\PropertyId;
-use Wikibase\DataModel\Services\Statement\V4GuidGenerator;
-use Wikibase\DataModel\Statement\StatementGuid;
-use WikibaseQuality\ExternalValidation\EvaluateCrossCheckJobService;
-use WikibaseQuality\ExternalValidation\DumpMetaInformation\DumpMetaInformation;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\ComparisonResult;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\ReferenceResult;
-use Wikibase\DataModel\Reference;
-use Wikibase\Lib\ClaimGuidGenerator;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResult;
-use WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList;
-
-
-/**
- * @covers WikibaseQuality\ExternalValidation\EvaluateCrossCheckJobService
- *
- * @group WikibaseQualityExternalValidation
- *
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class EvaluateCrossCheckJobServiceTest extends \MediaWikiTestCase {
-
-       private $entity;
-       private $checkTimestamp;
-       private $results;
-       private $params;
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->entity = new Item();
-               $this->entity->setId( new ItemId( 'Q23' ) );
-
-               $this->checkTimestamp = wfTimestamp( TS_MW );
-
-               $propertyId = new PropertyId( 'P188' );
-               $identifierPropertyIds = array( new PropertyId( 'P42' ) );
-
-               $guidGenerator = new V4GuidGenerator();
-               $itemId = new ItemId( 'Q42' );
-               $claimGuid = $itemId->getSerialization() . 
StatementGuid::SEPARATOR . $guidGenerator->newGuid();
-
-               $externalId = 'foobar';
-
-               $dumpMetaInformation = new DumpMetaInformation( 'dumpId', 
$itemId, $identifierPropertyIds, '20150101000000', 'irrelevent', 
'http://irrelevant.org', 100, $itemId );
-
-               $comparisonResultViolation = new ComparisonResult( new 
StringValue( 'foo' ), array( new StringValue( 'bar' ) ), 
ComparisonResult::STATUS_MISMATCH );
-               $comparisonResultCompliance = new ComparisonResult( new 
StringValue( 'foo' ), array( new StringValue( 'foo' ) ), 
ComparisonResult::STATUS_MATCH );
-
-               $referenceResultMissing = new ReferenceResult( 
ReferenceResult::STATUS_REFERENCES_MISSING, new Reference() );
-               $referenceResultExisting = new ReferenceResult( 
ReferenceResult::STATUS_REFERENCES_STATED, new Reference() );
-
-               $results = array();
-               $results[] = new CrossCheckResult( $propertyId, $claimGuid, 
$externalId, $dumpMetaInformation, $comparisonResultViolation, 
$referenceResultMissing );
-               $results[] = new CrossCheckResult( $propertyId, $claimGuid, 
$externalId, $dumpMetaInformation, $comparisonResultViolation, 
$referenceResultExisting );
-               $results[] = new CrossCheckResult( $propertyId, $claimGuid, 
$externalId, $dumpMetaInformation, $comparisonResultCompliance, 
$referenceResultMissing );
-               $results[] = new CrossCheckResult( $propertyId, $claimGuid, 
$externalId, $dumpMetaInformation, $comparisonResultCompliance, 
$referenceResultExisting );
-               $this->results = new CrossCheckResultList( $results );
-
-               $this->checkTimestamp = wfTimestamp( TS_MW );
-
-               $this->params = array( 'entityId' => 
$this->entity->getId()->getSerialization(), 'referenceTimestamp' => null, 
'results' => $results );
-       }
-
-       protected function tearDown() {
-               unset( $this->results, $this->entity, $this->checkTimestamp );
-               parent::tearDown();
-       }
-
-       public function testBuildResultSummary() {
-               $service = new EvaluateCrossCheckJobService();
-               $this->assertEquals( '{"Matches with reference":1,"Matches 
without reference":1,"Partial matches with reference":0,"Partial matches 
without reference":0,"Mismatches with reference":1,"Mismatches without 
reference":1}', $service->buildResultSummary( $this->results ) );
-       }
-
-       public function testBuildMessageForLog() {
-               $service = new EvaluateCrossCheckJobService();
-               $messageToLog = (array)json_decode( 
$service->buildMessageForLog( '{"Matches with reference":1,"Matches without 
reference":1,"Partial matches with reference":0,"Partial matches without 
reference":0,"Mismatches with reference":1,"Mismatches without reference":1}', 
$this->checkTimestamp, $this->params ) );
-
-               $this->assertEquals( 5, count( $messageToLog ) );
-               $this->assertEquals( 'SpecialCrossCheck', 
$messageToLog['special_page_id'] );
-               $this->assertEquals( 
$this->entity->getId()->getSerialization(), $messageToLog['entity_id'] );
-               $this->assertEquals( $this->checkTimestamp, 
$messageToLog['insertion_timestamp'] );
-               $this->assertEquals( null, $messageToLog['reference_timestamp'] 
);
-
-               $resultSummary = (array)json_decode( 
$messageToLog['result_summary'] );
-               $this->assertEquals( 6, count( $resultSummary ) );
-
-               $this->assertEquals( 1, $resultSummary['Matches with 
reference'] );
-               $this->assertEquals( 1, $resultSummary['Matches without 
reference'] );
-               $this->assertEquals( 0, $resultSummary['Partial matches with 
reference'] );
-               $this->assertEquals( 0, $resultSummary['Partial matches without 
reference'] );
-               $this->assertEquals( 1, $resultSummary['Mismatches with 
reference'] );
-               $this->assertEquals( 1, $resultSummary['Mismatches without 
reference'] );
-       }
-
-       public function testGetResults() {
-               $service = new EvaluateCrossCheckJobService();
-               $this->assertEquals( $this->results->toArray(), 
$service->getResults( $this->params ) );
-       }
-
-}
diff --git a/tests/phpunit/Specials/SpecialCrossCheckTest.php 
b/tests/phpunit/Specials/SpecialCrossCheckTest.php
index 7f5e672..1c9fb0e 100755
--- a/tests/phpunit/Specials/SpecialCrossCheckTest.php
+++ b/tests/phpunit/Specials/SpecialCrossCheckTest.php
@@ -40,7 +40,6 @@
  * @uses   WikibaseQuality\ExternalValidation\CrossCheck\Result\ReferenceResult
  * @uses   
WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResult
  * @uses   
WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList
- * @uses   WikibaseQuality\ExternalValidation\EvaluateCrossCheckJobService
  * @uses   WikibaseQuality\Html\HtmlTableBuilder
  * @uses   WikibaseQuality\Html\HtmlTableHeaderBuilder
  * @uses   WikibaseQuality\Html\HtmlTableCellBuilder
@@ -429,4 +428,4 @@
 
                return $cases;
        }
-}
\ No newline at end of file
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/237430
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98d0d471fdd24c749b44dae70082e2d59cc61c0e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityExternalValidation
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to