Page MenuHomePhabricator

Contributor gets their own contributions
Closed, ResolvedPublic

Description

Story

"As a Contributor, I want to get a list of revisions that I have made, to get a sense of the scale and importance of my own work."

A rough equivalent of the user contributions page in REST form. Compare T235073, which gets the contributions for other users.

Done Criteria

  • A non-logged-in client will receive a Status 401 Patch
  • Returns a list of N page revisions by the current logged-in user Patch
    • Response object must be JSON
    • Response object must contain the following fields:
    • revisions: an array of 0 to segment_size limit revision objects, each with the following information:
      • id: revision id
      • comment: edit summary of the change, provided by the user
      • timestamp: date of change, YYYY-MM-DDTHH:MM:SSZ
      • size: count of bytes
      • page: Page that was modified, JSON object with the following properties: {id, key, title} (see the schema for details)
  • Suppressed revisions are not exposed to unauthorized users, but visible to authorized users Patch
  • Client should be able to request the next (earlier in time) segments The response should contain the following properties: Patch
    • "older": Full link to API endpoint + "before|" + rev ID or rev timestamp. May be null if there are no known older revisions.
  • Client should be able to request the previous (later in time) segments. The response should contain the following properties: Patch
    • "older": Full link to API endpoint + "before|" + rev ID or rev timestamp. May be null if there are no known older revisions.
    • "newer": Full link to API endpoint + "after|" + rev ID or rev timestamp
    • "latest": Full link to API endpoint without parameters
  • There is a stable chronological order among the revisions, based on the combination of revision ID AND revision timestamp Patch
  • Each revision should also have the field: delta: +/- count of bytes changed from previous Patch
  • Each revision should also have the field: tags: array of Tag objects with [ tag, url ], per schema Patch

Designs/Interface/Mockups

GET /me/contributions?segment=<segment-marker>&limit=<segment_size>

Segmented contribution history by user with name name. (I'm calling it "segmented" instead of "paged" so we don't all go crazy.)

segment_marker: ( "before" | "after" ) "|" timestamp "|" revision_id
segment_size: size of the segment to get; minimum is 1, default is 20, and maximum 100

Request body: none

Notable request headers: none

Status:
200 - OK
401 - not authenticated
400 - invalid segment marker or segment size is out of bounds

Notable response headers: none

Body: JSON, an object with the following fields:
older: full link to API endpoint for the next older segment of results. oldest segment will have this field null. all other segments will have a value.
newer: full link to API endpoint for the next newer segment of results. This will never be null (to account for edits occurring after we get results)
latest: full link to API endpoint for the latest values, usually just this endpoint with no parameters
revisions: an array of 0 to 20 revision objects, in reverse chronological order, each with the following information:
id: revision id
comment: edit summary of the change, provided by the user
timestamp: date of change, YYYY-MM-DDTHH:MM:SSZ
delta: +/- count of bogobytes changed from previous
size: count of bogobytes
page: Page that was modified, JSON object with the following properties: {id, key, title} (see schema for details)
tags: array of Tag objects (see schema)

Related Stories

"As a Reader, I want to get a list of revisions of pages a Contributor has created or updated, because I want to read more of what they have written."

"As a Contributor, I want to get a list of revisions of pages another Contributor has created or updated, because I want to contribute to pages that are similar to ones that I've collaborated on with that person."

"As a Curator, I want to get a list of revisions of pages a Contributor has created or updated, because they may have made a repeated mistake on multiple pages."

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Some edge cases to be specified:

  • Contributions to pages now deleted. Special:Usercontribs does not show these
  • Deleted revisions. Special:Usercontribs does not show these
  • Suppressed contributions. Special:Usercontribs does list these, with the suppressed aspects hidden (user name, summary, or content can be suppressed)
  • The notion of "previous" is ill-defined: revisions have a parent revision, but this may end up not being the previous revision in the page history (due to revision deletion, history merge, import). Because of this, Special:Usercontribs just calculates the diff link and size delta against the revision previous in the history. This way, diffs and delta are consistent with the nominal chronology, but do not necessarily reflect what the user actually did at the time of editing. See discussion on T193211, T186280, T193690, T223343, etc.

Change 596011 had a related patch set uploaded (by Nikki Nikkhoui; owner: Nikki Nikkhoui):
[mediawiki/core@master] UserContributions Endpoint

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

eprodromou updated the task description. (Show Details)
eprodromou updated the task description. (Show Details)

@eprodromou question: I'm still a little confused by the "segment" param, the syntax is unclear to me by how it is written in the description. (Using timestamp below as an example)

/me/contributions?segment=before:2020-05-05
/me/contributions?before=2020-05-05

The second one is what i would expect but the example url in the task description has "segment" as a query param so just wanted to clarify!
Also, other endpoints (https://phabricator.wikimedia.org/T235073) use older_than, curious why we are using "before" instead of "older_than" here ?

Change 601900 had a related patch set uploaded (by Nikki Nikkhoui; owner: Nikki Nikkhoui):
[mediawiki/core@master] UserContributions Endpoint Returns 401 Unauthorized

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

Change 602141 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] UserContributionsHandler: return revisions

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

Change 602336 had a related patch set uploaded (by Daniel Kinzler; owner: Nikki Nikkhoui):
[mediawiki/core@master] WIP: UserContributions Endpoint: paging forward

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

Change 602611 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] UserContributions endpoint: backwards paging

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

Change 602617 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] UserContributions endpoint: return deltas

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

@WDoranWMF this task is in progress, but there's no one assigned to it. Should it be in the To Do column instead?

@Naike Woops - added assignee. Daniel and I are working on this at the moment (But it only lets me add one user)

Change 603929 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] UserContributions endpoint: filter suppressed revisions

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

Change 601900 merged by jenkins-bot:
[mediawiki/core@master] REST me/contributions: Returns 401 Unauthorized

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

daniel updated the task description. (Show Details)

Change 602141 merged by jenkins-bot:
[mediawiki/core@master] REST /me/contributions: return revisions

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

Change 602336 merged by jenkins-bot:
[mediawiki/core@master] REST /me/contributions: allow paging forward

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

Change 602611 merged by jenkins-bot:
[mediawiki/core@master] REST /me/contributions: implement backwards paging

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

daniel updated the task description. (Show Details)

Change 603929 merged by jenkins-bot:
[mediawiki/core@master] UserContributions endpoint: filter suppressed revisions

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

We hit a snag with the "stable paging" requirement, as details in T200259: While we could implement stable paging based on timestamp and revision ID for a vanilla MediaWiki install, there are extensions (most notably Flow) that inject "contributions" that are not revisions. It be additional effort to ensure we are not breaking such extensions when changing how the paging works. But more importantly, it's unclear even on a conceptual level how stable paging could work if extensions can mix in arbitrary kinds of "contributions" that do not share a set of unique keys. We will leave the resolution of this issue for later.

Change 596011 merged by jenkins-bot:
[mediawiki/core@master] REST /me/contributions: return change tags

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

Change 607994 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] ContributionsSegmentTest: test deltas

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

Change 602617 merged by jenkins-bot:
[mediawiki/core@master] UserContributions endpoint: return deltas

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

Change 607994 merged by jenkins-bot:
[mediawiki/core@master] ContributionsSegmentTest: test deltas

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

See https://phabricator.wikimedia.org/T235073#6322753 . The tags array has strings, not objects. Other than that, this looks good.

I'm moving this back to "Ready", since the Tag structure still isn't there. I've updated the schema to show the appearance and appearance_source properties.

Checking here: https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/me/contributions

...I only see string tags.

I've moved the requirement to add appearance and appearance_source to a separate ticket T259716. So we really just need to have the tags as a structure rather than a string, so that it's future-compatible when we add more properties.

Change 618640 had a related patch set uploaded (by Nikki Nikkhoui; owner: Nikki Nikkhoui):
[mediawiki/core@master] Make array of tags with property 'text'

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

Change 618640 merged by jenkins-bot:
[mediawiki/core@master] Make array of tags with property 'text'

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

@eprodromou, why did you move this story back to documentation?

Docs for this endpoint have been reviewed and are ready to be published when this endpoint goes into v1.