I have a question about the semantics of child_count
in the comment list API endpoint. Sorry for being related to an earlier question but I haven’t quite figured it out yet.
My assumption was that child_count
would indicate the amount of total descendants of a comment, regardless of depth. But take this case for example:
$ curl 'https://lemmy.ml/api/v3/comment/list?parent_id=2157873&%3Bmax_depth=999&%3Blimit=999' | jq '.comments[]
| { path: .comment.path, id: .comment.id, content: .comment.content, child_count: .counts.child_count }'
{
"path": "0.2157873",
"id": 2157873,
"content": "Really cool! I'm excited to learn more about you and the project!\n\nWhat's the format? Should we submit questions beforehand, or will you process questions that arrive at the start time? I've never participated in an AMA 😅 ",
"child_count": 9
}
{
"path": "0.2157873.2158260",
"id": 2158260,
"content": "You just post questions as top-level replies to the stickied thread that day, and we'll be online to answer them.",
"child_count": 6
}
{
"path": "0.2157873.2158260.2158286",
"id": 2158286,
"content": "Cool. Thank you for doing this!",
"child_count": 1
}
{
"path": "0.2157873.2158260.2229041",
"id": 2229041,
"content": "Post doesn’t mention, where is the AMA? Here or in a different community?",
"child_count": 3
}
{
"path": "0.2157873.2158260.2158286.2158743",
"id": 2158743,
"content": "No probs!",
"child_count": 0
}
{
"path": "0.2157873.2158260.2229041.2231423",
"id": 2231423,
"content": "As the post mentions, it will be stickied to the top of lemmy.ml ",
"child_count": 2
}
{
"path": "0.2157873.2158260.2229041.2231423.2231737",
"id": 2231737,
"content": "Thanks for the details. May be I’m missing something, but I don’t see that detail in the post. ![](https://programming.dev/pictrs/image/82c90859-9cfb-4c00-80d8-7e96bfd96c1c.jpeg)",
"child_count": 1
}
{
"path": "0.2157873.2158260.2229041.2231423.2231737.2238347",
"id": 2238347,
"content": "Oops my bad, that was something I responded to in a comment.",
"child_count": 0
}
I see that comment 2157873 has a child count of 9, with one direct descendant (2158260). The descendant has a child count of 6. I’d reason that comment 2157873 has 2 direct descendants that aren’t visible in the API response yet, because it has one visible descendant having a child count of 6 (i.e. 9 - 1 - 6 = 2). My calculation seems incorrect because (a) I don’t see a ‘Load more’ indicator for this part of the comment thread on https://lemmy.ml/post/2671212, and (b) every comment shown there also seems present in the API response.
Am I understanding the meaning of child_count
correctly?
I took a look at how the official Lemmy UI uses
child_count
, and it appears to use the number verbatim in its “X more replies” link. So if a comment tree were to include deleted comments, butchild_count
includes the deleted ones, I’d assume the displayed number would be incorrect.Also, it appears that it only displays a load more link if no child comments are currently loaded for that comment and
child_count
is bigger than 0.