import logging
import argparse
from pathlib import Path
-from budget_sync.util import all_bugs
+from budget_sync.util import all_bugs, tty_out
from budget_sync.config import Config, ConfigParseError
from budget_sync.budget_graph import BudgetGraph, PaymentSummary
from budget_sync.write_budget_markdown import (write_budget_markdown,
output_dir: Path):
"""reports milestones as json format
"""
+ bug_comments_map = {}
+ if add_comments:
+ need_set = set()
+ bugzilla = None
+ for nodes in budget_graph.assigned_nodes_for_milestones.values():
+ for node in nodes:
+ need_set.add(node.bug.id)
+ bugzilla = node.bug.bugzilla
+ need_list = sorted(need_set)
+ total = len(need_list)
+ with tty_out() as term:
+ step = 100
+ i = 0
+ while i < total:
+ cur_need = need_list[i:i + step]
+ stop = i + len(cur_need)
+ print(f"loading comments {i}:{stop} of {total}",
+ flush=True, file=term)
+ comments = bugzilla.get_comments(cur_need)['bugs']
+ if len(comments) < len(cur_need) and len(cur_need) > 1:
+ step = max(1, step // 2)
+ print(f"failed, trying smaller step of {step}",
+ flush=True, file=term)
+ continue
+ bug_comments_map.update(comments)
+ i += len(cur_need)
for milestone, payments in budget_graph.milestone_payments.items():
summary = PaymentSummary(payments)
# and one to display people
intro = []
comment = "%s\n " % child.bug_url
if add_comments:
- comments = child.bug.getcomments()
+ comments = bug_comments_map[str(child.bug.id)]['comments']
comment += "\n%s" % comments[0]['text']
intro.append(comment)
# print (description, intro)