From 26b5a11fd60393aac1cd936bf55eba6fc4cb3962 Mon Sep 17 00:00:00 2001 From: John Strunk Date: Thu, 23 May 2024 15:40:32 +0000 Subject: [PATCH] Restart issue recursion if child issue is allowed to have a summary Signed-off-by: John Strunk --- summarizer.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/summarizer.py b/summarizer.py index b6aad99..f7cc9a6 100644 --- a/summarizer.py +++ b/summarizer.py @@ -52,14 +52,13 @@ _wrapper = text_wrapper.TextWrapper(SUMMARY_START_MARKER, SUMMARY_END_MARKER) -# pylint: disable=too-many-locals -# pylint: disable=too-many-branches -def summarize_issue( +def summarize_issue( # pylint: disable=too-many-arguments,too-many-branches,too-many-locals issue: Issue, max_depth: int = 0, send_updates: bool = False, regenerate: bool = False, return_prompt_only: bool = False, + current_depth: int = 0, ) -> str: """ Summarize a Jira issue. @@ -91,12 +90,21 @@ def summarize_issue( # if we have not reached max-depth, summarize the child issues for inclusion in this summary child_summaries: List[Tuple[RelatedIssue, str]] = [] for child in issue.children: - if max_depth > 0: + if current_depth < max_depth: child_issue = issue_cache.get_issue(issue.client, child.key) + # If the child issue is allowed to have a summary, we restart our + # recursion since it should get the full benefit of the recursion. + new_depth = 0 if is_ok_to_post_summary(child_issue) else current_depth + 1 child_summaries.append( ( child, - summarize_issue(child_issue, max_depth - 1, send_updates, False), + summarize_issue( + child_issue, + max_depth=max_depth, + send_updates=send_updates, + regenerate=False, + current_depth=new_depth, + ), ) ) else: