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

chore(github): Remove debugging code #83986

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 2 additions & 16 deletions src/sentry/integrations/github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ def get_repos(self, fetch_max_pages: bool = False) -> list[dict[str, Any]]:
It uses page_size from the base class to specify how many items per page.
The upper bound of requests is controlled with self.page_number_limit to prevent infinite requests.
"""
# XXX: In order to speed up this function we could use ThreadPoolExecutor
# to fetch repositories in parallel. See src/sentry/utils/snuba.py
Copy link
Member Author

Choose a reason for hiding this comment

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

This is already mentioned inside of get_with_pagination
image

repos = self.get_with_pagination(
"/installation/repositories",
response_key="repositories",
Expand Down Expand Up @@ -551,31 +549,19 @@ def get_with_pagination(
output = []

page_number = 1
logger.info("Page %s: %s?per_page=%s", page_number, path, self.page_size)
resp = self.get(path, params={"per_page": self.page_size})
output.extend(resp) if not response_key else output.extend(resp[response_key])
next_link = get_next_link(resp)

# XXX: Debugging code; remove afterward
if (
response_key
and response_key == "repositories"
and resp["total_count"] > 0
and not output
):
logger.info("headers: %s", resp.headers)
logger.info("output: %s", output)
logger.info("next_link: %s", next_link)
logger.error("No list of repos even when there's some. Investigate.")

# XXX: In order to speed up this function we will need to parallelize this
# Use ThreadPoolExecutor; see src/sentry/utils/snuba.py#L358
while next_link and page_number < page_number_limit:
# If a per_page is specified, GitHub preserves the per_page value
# in the response headers.
resp = self.get(next_link)
output.extend(resp) if not response_key else output.extend(resp[response_key])

next_link = get_next_link(resp)
logger.info("Page %s: %s", page_number, next_link)
page_number += 1
return output

Expand Down
1 change: 0 additions & 1 deletion src/sentry/integrations/github/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def get_next_link(response: Response) -> str | None:
"""
link_option: str | None = response.headers.get("link")
if link_option is None:
logger.info("There are no pages to iterate on.")
return None

# Should be a comma separated string of links
Expand Down
Loading