Page MenuHomePhabricator

Contributor gets own contribution count
Closed, ResolvedPublic

Description

"As a Contributor, I want to get a count of my own contributions, to know how much work I've done for the project."

GET /user/{name}/contributions/count
GET /me/contributions/count

Count of contributions by a given user with username name.

The synonym /me/contributions/count can be used to get the count of the current logged-in user's contributions.

{name} is the user name.

Request body: none

Notable request headers: none

Status:
200 - OK
401 - not authenticated; only used for the /me synonym
404 – no such user

Notable response headers: none

Body: JSON, an object with the following fields:
count: total number of contributions by the user

Event Timeline

Change 605891 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] REST me/contributions/count endpoint

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

Counting revisions created by a user is simple enough, but as we discovered during our work on T200259, not all contributions are revisions, some or other things defined by extensions (e.g. discussion contributions from the Flow extension). That complicates things a lot. We would have to live with an inconsistency between the number of contributions listed by /me/contributions, and the number returned by /me/contributions/count for now. We can then introduce a new hook that allows extensions to add to that number to make things consistent again.

Change 605891 merged by jenkins-bot:
[mediawiki/core@master] REST me/contributions/count endpoint

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

Does this ticket represent both /me/contributions/count and /user/{name}/contributions/count? The later doesn't seem to be supported currently.

wow ok your due diligence has uncovered that yes I think we just forgot to implement that one....theres no route for it and the user in UserContributionsCount defaults to "me". @daniel I can work on that one now. It shouldn't take too long.

wow ok your due diligence has uncovered that yes I think we just forgot to implement that one....theres no route for it and the user in UserContributionsCount defaults to "me". @daniel I can work on that one now. It shouldn't take too long.

Ha - i ignored the second route in the task description, because the title says "Contributor gets *own* contribution count".

Implementing this is easy enough, writing the tests takes some time.

@nnikkhoui, here's the draft of the docs for the contribution endpoints for your review! Feel free to make edits directly to the page, leave comments on the talk page, or leave your feedback here on the task; whatever works best for you :) The examples currently show the beta wiki but will be changed to a non-beta wiki when published to the main docs.

Docs have been reviewed (Thanks, @nnikkhoui!) and are ready to be published once the contribution endpoints go into v1