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&max_depth=999&limit=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?

  • RoundSparrow@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    I’ve been studying the underlying PostgreSQL content of path and how child_count gets done the last few days…

    First off, is this consistent - as there are some questions about deleted comments, removed comments, personal blocking of users who create comments, banned from community person who created comments, etc. Your API with curl doesn’t have an auth on it, so personal blocking shouldn’t be a factor (not logged in).

    max_depth=999 limit=999

    I’m not sure how lemmy_server behaves when ranges are out of bounds here. limit on comments is 300 hard-coded in the Rust code AFAIK, and max_depth like around 15.

    I think child_count is intended to mean all generations of children, not “direct replies to this comment” count. In your example:

      "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
    

    The child_count looks correct, hand-counting I get 6 that are all originating off of 2158260.

      "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
    

    Also looks correct, I see a child and a grandchild, totaling 2 comments in the way I understand they intend to 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
    
    

    I would expect 7 given what you show. Are 2 reply comments deleted, removed?

    I do KNOW that in version 0.18.4 - the SQL that updates comment_aggregates child_count does NOT look at deleted or removed. It suspect it always counts them as children, even if you as a non-moderator, non-administrator can not fetch them. The fetch policy has changed in 0.18.x releases, it used to be you could indeed load deleted comments and even see their content.

    As I said first off, is this consistent? Can we find a 9-count comment tree that has all 9 where there are no delete or remove at play.