Expose number of comments in rest/bug API call

RESOLVED DUPLICATE of bug 994896

Status

()

RESOLVED DUPLICATE of bug 994896
3 years ago
3 years ago

People

(Reporter: leifer, Unassigned)

Tracking

5.0.3

Details

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce:

Use the rest api to return a bug

e.g. https://landfill.bugzilla.org/bugzilla-5.0-branch/rest/bug/1


Actual results:

The number of comments for that bug is not listed. A second query like this is required to find that out.

e.g. https://landfill.bugzilla.org/bugzilla-5.0-branch/rest/bug/1/comment

From the response, I check the size of the comments array.


Expected results:

It'd be helpful if the initial rest/bug query returned a new field representing the number of comments the bug has (e.g. "comments_count"?).

The background for this is that I'm helping build a a kanban board for Bugzilla (https://github.com/leif81/bzkanban), each bug is represented as a card on the board. What we want to do is display the number of comments a bug has on each card (think Trello). With the current API this means an additional N queries, where N is the number of bugs on the board. In some cases this could be > 100, which can add several seconds of additional latency when loading the board.

Thoughts? I'm open to other alternatives too.
A simple workaround for now is to use the deprecated BzAPI:

https://wiki.mozilla.org/Bugzilla:BzAPI:Methods#Retrieve_bug_.28.2Fbug.2F.3Cid.3E_GET.29
https://bugzilla.mozilla.org/bzapi/bug/1289166?include_fields=_all

I'm using the current API with Promise that calls 5 methods to retrieve comments, attachments, history, last visited timestamp (and duplicates, once Bug 880163 is solved on production) as well, which is certainly not ideal. Hope the Bugzilla API 2.0 would support all-in-one calls like BzAPI.

https://github.com/bzdeck/bzdeck/blob/master/webroot/static/scripts/collections/bugs.js#L35
Could just finishing bug 994896 work for this? If you add comments to the included fields you would get the comments back from Bug.get and obviously would know how many comments then. We could make it where you could only include comments.id which may speed up the call if all you want is the count.

dkl
Oh yeah, that's the bug I'd like to see fixed ;)
(Reporter)

Comment 4

3 years ago
(In reply to David Lawrence [:dkl] from comment #2)
> Could just finishing bug 994896 work for this? If you add comments to the
> included fields you would get the comments back from Bug.get and obviously
> would know how many comments then. We could make it where you could only
> include comments.id which may speed up the call if all you want is the count.
> 
> dkl

Cool. That would work well for me.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 994896
You need to log in before you can comment on or make changes to this bug.