Page MenuHomePhabricator

Fetch information from the similar_users API
Open, Needs TriagePublic

Description

Background

In order to display information about similar editors, we need to be able to fetch information about them from the similar_users API.

We should work with interfaces and domain objects in order to make it easier to stub the similar_users API during development and testing on the Beta Cluster.

AC
  • We have programatic access to the similar_users API, e.g.
use MediaWiki\Extension\SimilarEditors\SimilarUsersClient;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentityValue;

$similarUsersBaseUrl = '...';
$target = new UserIdentityValue( 1234567890, 'Foo' );

$httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory();
$client = new SimilarUsersClient( $httpRequestFactory, $similarUsersBaseUrl );
$result = $client->getSimilarUsers( $target );
  • The API returns domain objects, i.e. the signature of SimilarUsersClient::getSimilarUsers() above would be something like:
/**
  * @param UserIdentity $target
  * @return SimilarUser[] The list of users similar to the target user
  */
public function getSimilarUsers( UserIdentity $target ): array;
  • The base URL of the similar_users service is configurable
Notes
  1. The return type of the /v1/similarusers/ endpoint is documented (inline!) here: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/services/similar-users/+/refs/heads/main/similar_users/wsgi.py#121
  2. The high-level documentation of the service is here: https://wikitech.wikimedia.org/wiki/Similarusers
  3. In production, the base URLs of all services are available via $wgLocalServices, which is defined here: https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/944b45a6d4a47f00d7dcdafbc7ddb5e5a88a5f67/wmf-config/CommonSettings.php#140