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

refactor count_bugs to use libmozdata (#3676) #3704

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 7 additions & 6 deletions bugbug/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ def delete_bugs(match):
def count_bugs(bug_query_params):
bug_query_params["count_only"] = 1

r = utils.get_session("bugzilla").get(
"https://bugzilla.mozilla.org/rest/bug", params=bug_query_params
)
r.raise_for_status()
count = r.json()["bug_count"]
counts = []

def handler(bug):
counts.append(bug["bug_count"])

Bugzilla(bug_query_params, bughandler=handler).get_data().wait()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using bughandler expect to receive a response that has the property bugs: https://bugzilla.mozilla.org/rest/bug?id=1234567. However, passing the count_only returns JSON object that contains bug_count: https://bugzilla.mozilla.org/rest/bug?id=1234567&count_only=1

Thus, you need to pass the Query class to handle this, example:

Bugzilla(queries=Query(Bugzilla.API_URL, bug_query_params, handler)).wait()


return count
return sum(counts)


def get_product_component_count(months: int = 12) -> dict[str, int]:
Expand Down