Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart issue recursion if child issue is allowed to have a summary #83

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
Loading