fetchCommentCountDB
    :: Maybe (Key User)
    -> Key Project
    -> Key Discussion
    -> DB Int
fetchCommentCountDB muser_id project_id discussion_id = do
    let has_permission =
            exprCommentProjectPermissionFilter muser_id (val project_id)

    roots_ids <-
        map entityKey <$>
            fetchDiscussionRootCommentsDB discussion_id has_permission
    num_children <-
        length <$> fetchCommentsDescendantsDB roots_ids has_permission
    return $ length roots_ids + num_children
fetchCommentCountDB
    :: Maybe (Key User)
    -> Key Project
    -> Key Discussion
    -> DB Int
fetchCommentCountDB muser_id project_id discussion_id = do
    let has_permission =
            exprCommentProjectPermissionFilter muser_id (val project_id)

    roots_ids <-
        map entityKey <$>
            fetchDiscussionRootCommentsDB discussion_id has_permission
    num_children <-
        length <$> fetchCommentsDescendantsDB roots_ids has_permission
    return $ length roots_ids + num_children
fetchCommentCountDB muser_id project_id discussion_id = do
    let has_permission =
            exprCommentProjectPermissionFilter muser_id (val project_id)

    roots_ids <-
        map entityKey <$>
            fetchDiscussionRootCommentsDB discussion_id has_permission
    num_children <-
        length <$> fetchCommentsDescendantsDB roots_ids has_permission
    return $ length roots_ids + num_children