diff --git a/composer.json b/composer.json index a40c153..a9f6fdf 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "ext-iconv": "*", "ext-json": "*", "ext-intl": "*", + "ext-apcu": "*", "doctrine/annotations": "^2.0", "doctrine/doctrine-bundle": "^2.2", "phpxmlrpc/phpxmlrpc": "^4.10", diff --git a/i18n/en.json b/i18n/en.json index c307cf6..80881db 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -66,7 +66,6 @@ "record-url-text": "$1 of edit", "record-noeditor": "No editor found", "record-noeditor-tooltip": "The revision may have been deleted or the data is not yet available in Labs database.", - "record-damage": "Damage score: $1", "article": "Article", "compare-article-loading": "Loading article revision...", "compare-source-loading": "Loading possible copyvio source...", diff --git a/i18n/qqq.json b/i18n/qqq.json index d920e20..93d498d 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -77,7 +77,6 @@ "record-url-text": "Label text to show amount of plagiarism. Parameters:\n* $1 - Percentage of edit that was plagiarized.", "record-noeditor": "Column text shown to user when no editor was found in database for an edit", "record-noeditor-tooltip": "Tooltip for a text label, shown to editor to explain why no editor could be found", - "record-damage": "The damage score for a record.\nParameters: \n* $1 - Decimal number indicating percentage score.", "article": "Label shown for a text box, showing an article text. \n{{Identical|Article}}", "compare-article-loading": "Temporary text shown to user while article text loads", "compare-source-loading": "Temporary text shown to user while copyvio text source loads", diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index d411561..b80e27a 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -123,7 +123,7 @@ public function feedAction( } /** - * Returns a Record object, with additional data such as user edit counts, which pages are dead, and damage scores. + * Returns a Record object, with additional data such as user edit counts, and which pages are dead. * * @param array $rows * @param WikiRepository $wikiRepo @@ -160,11 +160,10 @@ public function decorateRecords( array $rows, WikiRepository $wikiRepo ): array $editCounts = $wikiRepo->getEditCounts( array_unique( $usernames ) ); $livePages = $wikiRepo->getLivePagesWithWikiProjects( $titlesByNs ); - $damageScores = $wikiRepo->getDamageScores( array_unique( $revIds ) ); $tagsAndComments = $wikiRepo->getRevisionMetadata( $revIds ); // Create a Record object for each row. - return array_map( static function ( $row ) use ( $editCounts, $livePages, $damageScores, $tagsAndComments ) { + return array_map( static function ( $row ) use ( $editCounts, $livePages, $tagsAndComments ) { // $tagsAndComments aren't indexed by rev_id, so we need to locate the row first. $extraData = array_filter( $tagsAndComments, static function ( $data ) use ( $row ) { return $data['rev_id'] === $row['rev_id']; @@ -182,8 +181,7 @@ public function decorateRecords( array $rows, WikiRepository $wikiRepo ): array isset( $livePages[$row['page_namespace']][$row['page_title']] ), isset( $livePages['2'][$row['rev_user_text']] ), isset( $livePages['3'][$row['rev_user_text']] ), - $livePages[$row['page_namespace']][$row['page_title']] ?? [], - $damageScores[$row['rev_id']] ?? null + $livePages[$row['page_namespace']][$row['page_title']] ?? [] ); }, $newRows ); } diff --git a/src/Model/Record.php b/src/Model/Record.php index 693e169..7e424d0 100644 --- a/src/Model/Record.php +++ b/src/Model/Record.php @@ -17,7 +17,6 @@ class Record { protected bool $userPageExists; protected bool $userTalkExists; protected array $wikiProjects; - protected ?float $damageScore; /** * @param array $row From the CopyPatrol database. @@ -26,7 +25,6 @@ class Record { * @param bool $userPageExists * @param bool $userTalkExists * @param array $wikiProjects - * @param float|null $damageScore */ public function __construct( array $row, @@ -34,8 +32,7 @@ public function __construct( bool $pageExists = false, bool $userPageExists = false, bool $userTalkExists = false, - array $wikiProjects = [], - float $damageScore = null + array $wikiProjects = [] ) { $this->data = $row; $this->editCount = $editCount; @@ -44,7 +41,6 @@ public function __construct( $this->userTalkExists = $userTalkExists; // Remove any null values. $this->wikiProjects = array_filter( $wikiProjects ); - $this->damageScore = $damageScore; } /** REPORT ATTRIBUTES */ diff --git a/src/Repository/WikiRepository.php b/src/Repository/WikiRepository.php index f153225..01289ed 100644 --- a/src/Repository/WikiRepository.php +++ b/src/Repository/WikiRepository.php @@ -274,49 +274,6 @@ private function getTagsLabels( array $tagNames ): array { return $messages; } - /** - * Get the damage scores for the given revision IDs. - * - * @param int[] $revIds - * @return array - */ - public function getDamageScores( array $revIds ): array { - if ( !$revIds ) { - return []; - } - - $dbName = "{$this->getLang()}wiki"; - - $ret = []; - $responses = []; - foreach ( $revIds as $revId ) { - if ( $this->cache->hasItem( "$dbName-damage-score-$revId" ) ) { - $ret[$revId] = $this->cache->getItem( "$dbName-damage-score-$revId" )->get(); - } else { - $responses[] = $this->httpClient->request( - 'POST', - "https://api.wikimedia.org/service/lw/inference/v1/models/$dbName-damaging:predict", - [ 'json' => [ 'rev_id' => $revId ] ] - ); - } - } - - foreach ( $responses as $response ) { - $data = $response->toArray( false ); - $revId = array_keys( $data[$dbName]['scores'] ?? [] )[0] ?? null; - if ( $revId ) { - $ret[$revId] = $data[$dbName]['scores'][$revId]['damaging']['score']['probability']['true'] ?? null; - $cacheItem = $this->cache->getItem( "$dbName-damage-score-$revId" ) - ->set( $ret[$revId] ) - ->expiresAfter( new DateInterval( 'PT10M' ) ); - $this->cache->saveDeferred( $cacheItem ); - } - } - $this->cache->commit(); - - return $ret; - } - /** * Return whether the language associated with this WikiRepository instance support PageAssessments. * diff --git a/templates/feed.html.twig b/templates/feed.html.twig index 05898bb..8ee9fe9 100644 --- a/templates/feed.html.twig +++ b/templates/feed.html.twig @@ -110,11 +110,6 @@