Skip to content
Open
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
17 changes: 11 additions & 6 deletions augur/tasks/github/pull_requests/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,23 +227,31 @@ def collect_pull_request_review_comments(repo_git: str, full_collection: bool) -
"""
owner, repo = get_owner_repo(repo_git)

review_msg_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/comments"

logger = logging.getLogger(collect_pull_request_review_comments.__name__)
logger.debug(f"Collecting pull request review comments for {owner}/{repo}")

key_auth = GithubRandomKeyAuth(logger)
github_data_access = GithubDataAccess(key_auth, logger)

if not github_data_access.check_prs_enabled(owner, repo):
logger.info(f"{owner}/{repo}: Pull requests appear to be disabled for this repo. Skipping review comment collection.")
return

repo_id = get_repo_by_repo_git(repo_git).repo_id

search_args = {}
if not full_collection:
last_collected_date = get_secondary_data_last_collected(repo_id)

if last_collected_date:
# Subtract 2 days to ensure all data is collected
core_data_last_collected = (last_collected_date - timedelta(days=2)).replace(tzinfo=timezone.utc)
review_msg_url += f"?since={core_data_last_collected.isoformat()}"
search_args["since"] = core_data_last_collected.isoformat()
else:
logger.warning(f"core_data_last_collected is NULL for recollection on repo: {repo_git}")

review_msg_url = github_data_access.endpoint_url(f"repos/{owner}/{repo}/pulls/comments", search_args or None)

pr_reviews = get_pull_request_reviews_by_repo_id(repo_id)

# Build mapping once: github pr_review_src_id -> augur pr_review_id
Expand All @@ -257,9 +265,6 @@ def collect_pull_request_review_comments(repo_git: str, full_collection: bool) -
tool_version = "2.0"
data_source = "Github API"

key_auth = GithubRandomKeyAuth(logger)
github_data_access = GithubDataAccess(key_auth, logger)

pr_review_comment_batch_size = get_batch_size()

# Batch processing: accumulate comments until batch size reached, then flush
Expand Down