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

Refactored count_bugs to use libmozdata #3687

Closed
wants to merge 5 commits into from

Conversation

rafey1104
Copy link

Fix #3676 @suhaibmujahid

Used Bugzilla class from libmozdata.bugzilla instead of doing a direct request

@suhaibmujahid
Copy link
Member

The libmozdata API is not used correctly. You could have a look at the example in #3676 as guidance.

Please test locally whether the function works correctly and make sure that your changes pass the CI tests.

I will cover the PR to draft; feel free to convert it back when it is ready for review.

@suhaibmujahid suhaibmujahid marked this pull request as draft October 4, 2023 15:32
@rafey1104
Copy link
Author

Before:-
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"]
return count

After:-
def count_bugs(bug_query_params):
count = Bugzilla(
queries={"bug_query_parameter": "1"},
bug_query_params={"count_only": 1}
).get_data().wait()
return count

I think now the API has been used correctly. How should I run the tests locally can you please guide me to some resources @suhaibmujahid ?

@suhaibmujahid
Copy link
Member

I think now the API has been used correctly.

Unfortunately, it is not :( See that example in the issue. Also, you could explore other places where that class is used.

How should I run the tests locally can you please guide me to some resources?

You do not need to run all existing tests locally to test the function. You could write a simple script/test to run it. Anyway, you could run the existing tests locally by running the following command:

python -m pytest tests/test_*.py

However, any time you push a commit to the PR, the tests will automatically run, and you can see the results. For example, the following are the results of your last comment: https://community-tc.services.mozilla.com/tasks/groups/Yf7oAmmcQJ-b4f7MOWFLGg

The commit failed on the lining task, not the tests. You could prevent that by using pre-commit. See https://github.com/mozilla/bugbug/tree/master#auto-formatting

@rafey1104 rafey1104 marked this pull request as ready for review October 9, 2023 19:40
@rafey1104 rafey1104 closed this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor count_bugs to use libmozdata
2 participants