Page MenuHomePhabricator

Add revision parameter to mwaddlink GET endpoint
Closed, ResolvedPublic

Description

When checking why a certain Add Link edit happened, it would be nice to be able to specify a revision to the mwaddlink API to be able to recreate the recommendation that the edit was based on.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The MediaWiki REST API does not support specifying a revision, so this would either involve undoing rRMWA36e052293fc8: Use rest.php for handling GET requests or waiting for T235239: Curator gets revision source.

Change 752608 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/deployment-charts@master] linkrecommendation: Add MEDIAWIKI_PROXY_API_BASE_URL

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

Change 752609 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[research/mwaddlink@main] Use api.php for handling GET requests

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

Change 752610 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[research/mwaddlink@main] Add revision parameter to API GET endpoint

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

Change 752611 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/vagrant@master] addlink: set MEDIAWIKI_API_BASE_URL

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

@Tgr as an alternative I proposed https://gerrit.wikimedia.org/r/c/mediawiki/core/+/752630, but if you prefer to switch to api.php I don't have a strong objection.

Change 752608 merged by jenkins-bot:

[operations/deployment-charts@master] linkrecommendation: Add MEDIAWIKI_PROXY_API_BASE_URL

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

Change 752609 merged by jenkins-bot:

[research/mwaddlink@main] Use api.php for handling GET requests

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

Change 752610 merged by jenkins-bot:

[research/mwaddlink@main] Add revision parameter to API GET endpoint

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

Change 756975 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[operations/deployment-charts@master] linkrecommendation: Bump chart version

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

Change 756975 merged by jenkins-bot:

[operations/deployment-charts@master] linkrecommendation: Bump chart version

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

Change 752611 merged by jenkins-bot:

[mediawiki/vagrant@master] addlink: set MEDIAWIKI_API_BASE_URL

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

Urbanecm_WMF changed the task status from Open to In Progress.Jan 31 2022, 11:33 AM
kostajh changed the task status from In Progress to Open.Feb 1 2022, 1:51 PM
kostajh moved this task from Code Review to QA on the Growth-Team (Current Sprint) board.
kostajh added a subscriber: Etonkovidova.

@Etonkovidova for QA, you can use https://api.wikimedia.org/service/linkrecommendation/apidocs to specify a revision number to check the recommendations for a specific revision of an article.

C19H29NO2 was selected as a test case - the revision 589294081 doesn't have link recommendation and the revision 1063338889 does have one. That was confirmed with API calls:

(the API calls are abbreviated)

$ curl -X POST https://api.wikimedia.org/service/linkrecommendation/v1/linkrecommendations/wikipedia/en/C19H29NO2 \
-H "Content-Type: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
--data '{"pageid": 41555364, "revid": 1063338889, "wikitext": "ADD_WIKITEXT_SOURCE"}'

{"pageid": 41555364, "revid": 1006639404, "wikitext":

 "links": [
    {
      "context_after": ": 303.44 g",
      "context_before": " (",
      "link_index": 0,
      "link_target": "Molar mass",
      "link_text": "molar mass",
      "match_index": 0,
      "score": 0.7418612837791443,
      "wikitext_offset": 135
    }
  ],
  "links_count": 1,

"page_title": "C19H29NO2",
"pageid": 41555364,
 "revid": 1063338889
$ curl -X POST https://api.wikimedia.org/service/linkrecommendation/v1/linkrecommendations/wikipedia/en/C19H29NO2 \
-H "Content-Type: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
--data '{"pageid": 41555364, "revid": 589294081 "wikitext": "ADD_WIKITEXT_SOURCE"}'
{
  "links": [],
  "links_count": 0,

 "page_title": "C19H29NO2",
  "pageid": 41555364,
  "revid": 589294081