Page MenuHomePhabricator

Add latest comment timestamp, number of comments, and number of editors in Discussion Tools API
Closed, ResolvedPublic

Description

In T402822: [SPIKE] How can we use DiscussionTools to retrieve the most active discussions on certain noticeboards? [8H], we investigated the feasibility of creating a feed of the most recently commented discussions from 2-5 different Wikipedia namespace pages. To achieve this, we would need to call the discussiontoolspageinfo API to parse and recursively go through every reply to count editors, comments, and determine the latest comment date.

This could be a performance bottleneck if there are many discussions per page with many replies. However, this information is already being calculated when DiscussionTools parses the page. If this information can be surfaced in an API call, it would make it easier for the Moderator Tools team to sort and filter the relevant discussions we want to surface in a dashboard module.

Event Timeline

This could be a performance bottleneck if there are many discussions per page with many replies.

I don't think iterating over the replies would be a performance bottleneck, it's just counting elements in a simple JSON structure. I think the main benefit here is just to prevent users from re-implementing the logic for calculating these things, which is still worthwhile.

Change #1189828 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/DiscussionTools@master] Include thread metadata in API response

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

Change #1189828 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Include thread metadata in API response

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

EAkinloose edited projects, added: Verified; removed: Editing QA.
EAkinloose subscribed.

Tested against https://en.wikipedia.org/wiki/Talk:Main_Page

Topics without comments return null for latestReplyTimestamp

{
                        "headingLevel": 2,
                        "name": "h-",
                        "type": "heading",
                        "level": 0,
                        "id": "h-Errors_with_\"In_the_news\"-Main_Page_error_reports",
                        "replies": [],
                        "html": "<span id=\"Errors_with_.22In_the_news.22\" typeof=\"mw:FallbackId\"></span>Errors with \"<a rel=\"mw:WikiLink\" href=\"./Template:In_the_news\" title=\"Template:In the news\" id=\"mwKQ\">In the news</a>\"",
                        "commentCount": 0,
                        "authorCount": 0,
                        "latestReplyTimestamp": null
}

For a topic with comments

...
"html": "The short description is Wikimedia template",
"commentCount": 3,
 "authorCount": 2,
"latestReplyTimestamp": "2025-11-15T23:02:00Z"