Feed of new comments (API v2 request)
Nimble Collective is looking for a way to have a feed of most recent comments. From what I see on APIv2, the comments endpoint requries a discussion ID or author ID, and can't just pull the ten most recent comments across the whole forum (or even for a particular category, which could work for their needs).
The RSS feed seems to be discussions as well, and I can't think of any other way to get a feed of all new comments.
Thoughts? Suggestions?
Quote from Customer:
I would love to be able to create a page that shows all the latest comments.. but may be able to do this with API2. do you know if that's going to be possible? To be able to do something like:
http://nimblecollective.vanillastaging.com/api/v2/comments/all.json
and then just pull the last.. say 10 or so as json?
if so, I should be able to use jquery to create a pocket that I only show when going to a certain url - giving me the ability to create a "latest activity" page that is actually the latest post activity.
Comments
-
You could pull the most recent 10 discussions, then grab the last comment from each. That is currently supported by API v2.
While it wouldn't be terrible to have an endpoint that can return the last 100 comments or so, it would be a serious problem to provide an "all" endpoint that allows you to paginate into the past.
I would frame it as a narrow request for limited "most recent" comments via API v2 for the R&D / CSM meetup.
0 -
Right now such a general endpoint is a scaling issue as we have no optimized query to get comments untethered to author or discussion. We could make an endpoint with an unpredictable number of records per page (as the user one is) but would probably not be able to add a category filter.
This is one where we would need more customer votes to put the work in. I feel as tough a recent comment stream would only work well for a tiny community but also that content without context would provide for a bad UX. I recommend we move on the featured content and try and push customers into that.
0 -
How does the promoted content module's comment only view work then? Or is it just OK that is makes an unoptimized query for them because we cache the result?
0 -
This is now being looked for by a bigger fish, Tripwire (3284 MRR):
Part of what we’re doing with the API is pulling down all the comment metadata. Unfortunately, I’ve not discovered how to do this efficiently.
With users and discussions, I can pull down all the data with just a few requests via the paging mechanism. With a page-size of 100, 650 users requires 7 requests. For 200 discussions, just 2 requests. To query for updates (all data after a certain date), that’s often just one request for users, and one for discussions.
However, I can only pull down comment data in in terms of a single discussion, or a single user as per the /comments API.
If you want to get data for comments and you have 200 discussions, that’s 200 separate requests (minimum) to get all the comment metadata we need.
If I want to get all the comments for just today, I have to make the same number of requests as I would get all the comments for all time.
Two questions:
Is there a way to avoid this that I’m somehow missing?
Could you find out if a more permissive way of getting comment metadata might be on your roadmap, and *fingers-crossed* if it might be soon?
Any ideas for Tripwire?
0 -
Also note that getting comments unattached to discussions cannot return consistent page sizes because we must query all comments then check permissions afterwards. This will lead to communities with very sparse permission structures to behave oddly on such an endpoint.
0 -
You can definitely search comments-only with the endpoint. To look up new comments since October 1st of this year, you could use the following request: https://example.vanilla.community/api/v2/search?recordTypes=comment&dateInserted=%3E%3D2018-10-01
The dateInserted parameter might look a little confusing, but that's because it's encoded for use in a URL there. The unencoded value looks like: >=2018-10-01, which just means we're looking for "comments added on or after (a DateInserted value greater-than or equal-to) October 1st, 2018".
5 -
Datorama also has questions around this:
1. We have thus far been unable to query your API to return the total number of Comments inserted for each date within the query time-frame, without having to query for the Discussions themselves, to which these Comments relate to. This is a huge problem for us because it means that in order to aggregate the number of Comments correctly, our query time-frame must be inclusive of all the Discussions ever created from the beginning of time. This causes potential time-out errors etc. So, is there a way to query for total number of Comments inserted for each date within the query time-frame with no connection to the related Discussions?
0