From f214f11c2f9ec53bc1586383e45bc608c009203e Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Mon, 14 Apr 2014 13:02:37 -0400 Subject: [PATCH] Use a MoreRecursion for too-deep child comments. --- r2/r2/models/builder.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/r2/r2/models/builder.py b/r2/r2/models/builder.py index 6ac7e53eb..c605218ca 100755 --- a/r2/r2/models/builder.py +++ b/r2/r2/models/builder.py @@ -883,11 +883,17 @@ class CommentBuilder(Builder): for child in visible_children) missing_count = num_children[visible_id] - visible_count missing_depth = depth.get(visible_id, 0) + 1 - offset_depth - mc = MoreChildren(self.link, depth=missing_depth, - parent_id=visible_id) - mc.children.extend(missing_children) - w = Wrapped(mc) - w.count = missing_count + + if missing_depth < self.max_depth: + mc = MoreChildren(self.link, depth=missing_depth, + parent_id=visible_id) + mc.children.extend(missing_children) + w = Wrapped(mc) + w.count = missing_count + else: + mr = MoreRecursion(self.link, depth=missing_depth, + parent_id=visible_id) + w = Wrapped(mr) # attach the MoreChildren parent = wrapped_by_id[visible_id]