this post was submitted on 24 Jun 2023
5 points (100.0% liked)

Lemmy App Development

788 readers
1 users here now

A place for Lemmy builders to chat about building apps, clients, tools and bots for the Lemmy platform.

On-Topic:

Off-Topic:

founded 2 years ago
MODERATORS
 

i have requests to fetch comment and post data, but i'm struggling to work out how to build a tree from the responses? do i fetch comments with arg parent_id to get a comment's children, and do so recursively for those comments returned that themselves have comments?

you are viewing a single comment's thread
view the rest of the comments
[–] blawsybogsy@lemmy.ml 1 points 2 years ago (9 children)

so "path" is a decimal separated list of comment ids? docs say nothing, but it looks like that.

[–] nmtake@lemm.ee 2 points 2 years ago (8 children)
[–] shootwhatsmyname@lemm.ee 1 points 2 years ago (6 children)

chiming in here because I’m trying to figure this out too. If there’s say, thousands of comments, and I don’t want to get all of them at once, how would I sort them based off the path? I don’t want to miss any replies to comments that are loaded, and it doesn’t appear that comments returned are sorted or grouped together in any way by default

[–] blawsybogsy@lemmy.ml 2 points 2 years ago (1 children)

interesting question. do you mean because if you use limit, and as results are returned unsorted, you might end up with children comments without their parents? have you actually had a go using limit to fetch from your 1000s of comments?

[–] shootwhatsmyname@lemm.ee 1 points 2 years ago

Yep exactly, I tested it and I do end up with orphaned comments no matter what I set as "limit" or "sort" (as long as limit is less than the total amount of comments). It's my guess that fetching a large list of comments would be slower than fetching a few, otherwise I'd just get all the comments in one go.

load more comments (4 replies)
load more comments (5 replies)
load more comments (5 replies)