Skip to content

Commit

Permalink
limit chapter depth at 400
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Feb 2, 2021
1 parent 0f9b88f commit c474980
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/study/src/main/ChapterRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ final class ChapterRepo(val coll: AsyncColl)(implicit
}

private def childrenTreeToBsonElements(parentPath: Path, children: Node.Children): Vector[(String, Bdoc)] =
children.nodes.flatMap { node =>
val path = parentPath + node
childrenTreeToBsonElements(path, node.children) appended (path.toDbField -> writeNode(node))
}
(parentPath.depth < Node.MAX_PLIES) ??
children.nodes.flatMap { node =>
val path = parentPath + node
childrenTreeToBsonElements(path, node.children) appended (path.toDbField -> writeNode(node))
}

private def setNodeValue[A: BSONWriter](
field: String,
Expand Down
2 changes: 2 additions & 0 deletions modules/study/src/main/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ case class Path(ids: Vector[UciCharPair]) extends AnyVal {
if (ids.isEmpty) s"root.${Path.rootDbKey}"
else s"root.${Path encodeDbKey this}"

def depth = ids.size

override def toString = ids.mkString
}

Expand Down

0 comments on commit c474980

Please sign in to comment.