Page MenuHomePhabricator

Fetch information from the similar_users API
Closed, ResolvedPublic8 Estimated Story Points

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.

(We should check that the API we worked with in T297684: Create a mock similar_users API client for development/QA on the Beta Cluster is still correct, and do the necessary updates if not.)

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

Details

Related Changes in Gerrit:

Related Objects

Event Timeline

Tchanders set the point value for this task to 8.Apr 19 2022, 4:25 PM

Change 792301 had a related patch set uploaded (by STran; author: STran):

[mediawiki/extensions/SimilarEditors@master] Fetch data from api

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

Change 792301 merged by jenkins-bot:

[mediawiki/extensions/SimilarEditors@master] Fetch data from api

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

@dom_walden @imaigwilo SimilarEditors is not on beta yet, pending T306909, so to test this requires similar-users to be set up locally (we found this non-trivial but doable).

Would you rather wait for it to be available on beta, or would a local setup be useful going forward? If the first one, I'll move this on and you can test it via an upcoming task. If the latter, we can help!

@dom_walden @imaigwilo SimilarEditors is not on beta yet, pending T306909, so to test this requires similar-users to be set up locally (we found this non-trivial but doable).

Would you rather wait for it to be available on beta, or would a local setup be useful going forward? If the first one, I'll move this on and you can test it via an upcoming task. If the latter, we can help!

Ideally I would like to setup it up locally. But if it takes too much time it might not be worth it.

I don't think there is much I can test here. According to @STran, this change added new classes and functions but they won't be used until T307023. I will move this along and test it along with the latter bug.