[MediaWiki-commits] [Gerrit] mediawiki...ORES[wmf/1.31.0-wmf.8]: Revert "Fallback to old thresholds API as necessary (take 2)"

2017-11-28 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/393959 )

Change subject: Revert "Fallback to old thresholds API as necessary (take 2)"
..


Revert "Fallback to old thresholds API as necessary (take 2)"

Do not deploy until all old thresholds servers are replaced.

Simplifies thresholds handling by dropping back-compatibility with revscoring 1.

This mutatedly reverts commit 451b61af4a5a2e00426d18820009466a1c033812.

Bug: T179602
Change-Id: I455859cf6877efef3da318bfcf0884ddf84964f1
---
M extension.json
D includes/ApiV1.php
M includes/Stats.php
D includes/StatsV1.php
D tests/phpunit/includes/ApiV1Test.php
M tests/phpunit/includes/StatsTest.php
D tests/phpunit/includes/StatsV1Test.php
7 files changed, 4 insertions(+), 498 deletions(-)

Approvals:
  jenkins-bot: Verified
  Awight: Looks good to me, approved



diff --git a/extension.json b/extension.json
index 00fe46a..c3ce04a 100644
--- a/extension.json
+++ b/extension.json
@@ -10,7 +10,6 @@
"url": "https://www.mediawiki.org/wiki/Extension:ORES;,
"AutoloadClasses": {
"ORES\\Api": "includes/Api.php",
-   "ORES\\ApiV1": "includes/ApiV1.php",
"ORES\\Cache": "includes/Cache.php",
"ORES\\Hooks": "includes/Hooks.php",
"ORES\\Hooks\\ApiHooksHandler": 
"includes/Hooks/ApiHooksHandler.php",
@@ -19,7 +18,6 @@
"ORES\\Range": "includes/Range.php",
"ORES\\Scoring": "includes/Scoring.php",
"ORES\\Stats": "includes/Stats.php",
-   "ORES\\StatsV1": "includes/StatsV1.php",
"ORES\\ApiQueryORES": "includes/ApiQueryORES.php",
"ORES\\WatchedItemQueryServiceExtension": 
"includes/WatchedItemQueryServiceExtension.php"
},
diff --git a/includes/ApiV1.php b/includes/ApiV1.php
deleted file mode 100644
index aa93e3e..000
--- a/includes/ApiV1.php
+++ /dev/null
@@ -1,90 +0,0 @@
-setOriginalRequest( 
RequestContext::getMain()->getRequest() );
-   }
-   return $self;
-   }
-
-   /**
-* @param WebRequest|string[] $originalRequest See 
MwHttpRequest::setOriginalRequest()
-*/
-   public function setOriginalRequest( $originalRequest ) {
-   $this->originalRequest = $originalRequest;
-   }
-
-   /**
-* @param string|null $model Name of the model to query
-* @return string Base URL plus your wiki's `scores` API path.
-*/
-   public function getUrl( $model = null ) {
-   global $wgOresBaseUrl, $wgOresWikiId;
-
-   if ( $wgOresWikiId ) {
-   $wikiId = $wgOresWikiId;
-   } else {
-   $wikiId = wfWikiID();
-   }
-   $url = "{$wgOresBaseUrl}scores/{$wikiId}/";
-   if ( $model ) {
-   $url .= "{$model}/";
-   }
-   return $url;
-   }
-
-   /**
-* Make an ORES API request and return the decoded result.
-*
-* @param array $params optional GET parameters
-* @param string|null $model Name of the model to query
-* @return array Decoded response
-*
-*/
-   public function request( $params = [], $model = null ) {
-   $logger = LoggerFactory::getInstance( 'ORES' );
-
-   $url = $this->getUrl( $model );
-   $params['format'] = 'json';
-   $url = wfAppendQuery( $url, $params );
-   $logger->debug( "Requesting: {$url}" );
-   $req = MWHttpRequest::factory( $url, 
$this->getMWHttpRequestOptions(), __METHOD__ );
-   $status = $req->execute();
-   if ( !$status->isOK() ) {
-   throw new RuntimeException( "Failed to make ORES 
request to [{$url}], "
-   . $status->getMessage()->text() );
-   }
-   $json = $req->getContent();
-   $logger->debug( "Raw response: {$json}" );
-   $data = FormatJson::decode( $json, true );
-   if ( !$data || !empty( $data['error'] ) ) {
-   throw new RuntimeException( "Bad response from ORES 
endpoint [{$url}]: {$json}" );
-   }
-   return $data;
-   }
-
-   protected function getMWHttpRequestOptions() {
-   return $this->originalRequest ? [ 'originalRequest' => 
$this->originalRequest ] : [];
-   }
-
-}
diff --git a/includes/Stats.php b/includes/Stats.php
index 934426e..bc0f04e 100644
--- a/includes/Stats.php
+++ b/includes/Stats.php
@@ -97,16 +97,10 @@
return $result;
} catch ( \RuntimeException $ex ) {
$statsdDataFactory->increment( 
'ores.api.stats.failed' );
- 

[MediaWiki-commits] [Gerrit] mediawiki...ORES[wmf/1.31.0-wmf.8]: Revert "Fallback to old thresholds API as necessary (take 2)"

2017-11-28 Thread Awight (Code Review)
Awight has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393959 )

Change subject: Revert "Fallback to old thresholds API as necessary (take 2)"
..

Revert "Fallback to old thresholds API as necessary (take 2)"

Do not deploy until all old thresholds servers are replaced.

Simplifies thresholds handling by dropping back-compatibility with revscoring 1.

This mutatedly reverts commit 451b61af4a5a2e00426d18820009466a1c033812.

Bug: T179602
Change-Id: I455859cf6877efef3da318bfcf0884ddf84964f1
---
M extension.json
D includes/ApiV1.php
M includes/Stats.php
D includes/StatsV1.php
D tests/phpunit/includes/ApiV1Test.php
M tests/phpunit/includes/StatsTest.php
D tests/phpunit/includes/StatsV1Test.php
7 files changed, 4 insertions(+), 498 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/59/393959/1

diff --git a/extension.json b/extension.json
index 00fe46a..c3ce04a 100644
--- a/extension.json
+++ b/extension.json
@@ -10,7 +10,6 @@
"url": "https://www.mediawiki.org/wiki/Extension:ORES;,
"AutoloadClasses": {
"ORES\\Api": "includes/Api.php",
-   "ORES\\ApiV1": "includes/ApiV1.php",
"ORES\\Cache": "includes/Cache.php",
"ORES\\Hooks": "includes/Hooks.php",
"ORES\\Hooks\\ApiHooksHandler": 
"includes/Hooks/ApiHooksHandler.php",
@@ -19,7 +18,6 @@
"ORES\\Range": "includes/Range.php",
"ORES\\Scoring": "includes/Scoring.php",
"ORES\\Stats": "includes/Stats.php",
-   "ORES\\StatsV1": "includes/StatsV1.php",
"ORES\\ApiQueryORES": "includes/ApiQueryORES.php",
"ORES\\WatchedItemQueryServiceExtension": 
"includes/WatchedItemQueryServiceExtension.php"
},
diff --git a/includes/ApiV1.php b/includes/ApiV1.php
deleted file mode 100644
index aa93e3e..000
--- a/includes/ApiV1.php
+++ /dev/null
@@ -1,90 +0,0 @@
-setOriginalRequest( 
RequestContext::getMain()->getRequest() );
-   }
-   return $self;
-   }
-
-   /**
-* @param WebRequest|string[] $originalRequest See 
MwHttpRequest::setOriginalRequest()
-*/
-   public function setOriginalRequest( $originalRequest ) {
-   $this->originalRequest = $originalRequest;
-   }
-
-   /**
-* @param string|null $model Name of the model to query
-* @return string Base URL plus your wiki's `scores` API path.
-*/
-   public function getUrl( $model = null ) {
-   global $wgOresBaseUrl, $wgOresWikiId;
-
-   if ( $wgOresWikiId ) {
-   $wikiId = $wgOresWikiId;
-   } else {
-   $wikiId = wfWikiID();
-   }
-   $url = "{$wgOresBaseUrl}scores/{$wikiId}/";
-   if ( $model ) {
-   $url .= "{$model}/";
-   }
-   return $url;
-   }
-
-   /**
-* Make an ORES API request and return the decoded result.
-*
-* @param array $params optional GET parameters
-* @param string|null $model Name of the model to query
-* @return array Decoded response
-*
-*/
-   public function request( $params = [], $model = null ) {
-   $logger = LoggerFactory::getInstance( 'ORES' );
-
-   $url = $this->getUrl( $model );
-   $params['format'] = 'json';
-   $url = wfAppendQuery( $url, $params );
-   $logger->debug( "Requesting: {$url}" );
-   $req = MWHttpRequest::factory( $url, 
$this->getMWHttpRequestOptions(), __METHOD__ );
-   $status = $req->execute();
-   if ( !$status->isOK() ) {
-   throw new RuntimeException( "Failed to make ORES 
request to [{$url}], "
-   . $status->getMessage()->text() );
-   }
-   $json = $req->getContent();
-   $logger->debug( "Raw response: {$json}" );
-   $data = FormatJson::decode( $json, true );
-   if ( !$data || !empty( $data['error'] ) ) {
-   throw new RuntimeException( "Bad response from ORES 
endpoint [{$url}]: {$json}" );
-   }
-   return $data;
-   }
-
-   protected function getMWHttpRequestOptions() {
-   return $this->originalRequest ? [ 'originalRequest' => 
$this->originalRequest ] : [];
-   }
-
-}
diff --git a/includes/Stats.php b/includes/Stats.php
index 934426e..bc0f04e 100644
--- a/includes/Stats.php
+++ b/includes/Stats.php
@@ -97,16 +97,10 @@
return $result;
} catch ( \RuntimeException $ex ) {
$statsdDataFactory->increment(