tchCommentDescendantsDB :: CommentId -> ExprCommentCond -> DB [Entity Comment]
fetchCommentDescendantsDB comment_id has_permission =
    select $
    from $ \c -> do
    where_ $
        has_permission c
        &&. c ^. CommentId `in_` (
            subList_select $
            from $ \ca -> do
            where_ (ca ^. CommentAncestorAncestor ==. val comment_id)
            return (ca ^. CommentAncestorComment))
    -- DO NOT change ordering here! buildCommentTree relies on it.
    orderBy [asc (c ^. CommentParent), asc (c ^. CommentCreatedTs)]
    return c

-- | Get all descendants of all given root comments.
f
fetchCommentDescendantsDB :: CommentId -> ExprCommentCond -> DB [Entity Comment]
fetchCommentDescendantsDB comment_id has_permission =
    select $
    from $ \c -> do
    where_ $
        has_permission c
        &&. c ^. CommentId `in_` (
            subList_select $
            from $ \ca -> do
            where_ (ca ^. CommentAncestorAncestor ==. val comment_id)
            return (ca ^. CommentAncestorComment))
    -- DO NOT change ordering here! buildCommentTree relies on it.
    orderBy [asc (c ^. CommentParent), asc (c ^. CommentCreatedTs)]
    return c

-- | Get all descendants of all given root comments.
fetchCommentDescendantsDB comment_id has_permission =
    select $
    from $ \c -> do
    where_ $
        has_permission c
        &&. c ^. CommentId `in_` (
            subList_select $
            from $ \ca -> do
            where_ (ca ^. CommentAncestorAncestor ==. val comment_id)
            return (ca ^. CommentAncestorComment))
    -- DO NOT change ordering here! buildCommentTree relies on it.
    orderBy [asc (c ^. CommentParent), asc (c ^. CommentCreatedTs)]
    return c

-- | Get all descendants of all given root comments.