Skip to content

Commit

Permalink
Check URLs before Dates
Browse files Browse the repository at this point in the history
  • Loading branch information
wrussell1999 committed Feb 8, 2024
1 parent 9f48ceb commit cf329cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
33 changes: 18 additions & 15 deletions git_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,25 @@ def find_issues_prs(response, projects, fellow):
url = '/'.join(item['html_url'].split('/')[:5]).lower()

# Check dates are within Batch Dates
local_date = datetime.datetime.strptime(item['created_at'], GITHUB_DATE_FORMAT)
if local_date >= batch_start and local_date <= batch_end:
print(f"Date within range - proceeding with {url}")
# Check PR is in the project
if url in projects and "pull_request" in item:
helpers.add_to_db(email=fellow, github_id=fellows[fellow]['github_userid'], github_username=fellows[fellow]['github_username'],
project=fellows[fellow]['project'], id=item['id'], url=item['html_url'], activity_type="Pull Request", message=item['title'],
number=item['number'], created_at=item['created_at'], closed_at=item['closed_at'], merged_at=item['pull_request']['merged_at'])
if url in projects:
local_date = datetime.datetime.strptime(item['created_at'], GITHUB_DATE_FORMAT)

if local_date >= batch_start and local_date <= batch_end:
print(f"Date within range - proceeding with {url}")

# Check Issue is in the project
elif url in projects and "pull_request" not in item:
helpers.add_to_db(email=fellow, github_id=fellows[fellow]['github_userid'], github_username=fellows[fellow]['github_username'],
project=fellows[fellow]['project'], id=item['id'], url=item['html_url'], activity_type="Issue", message=item['title'],
number=item['number'], created_at=item['created_at'], closed_at=item['closed_at'])
else:
print("Date not within batch")
# Check PR is in the project
if "pull_request" in item:
helpers.add_to_db(email=fellow, github_id=fellows[fellow]['github_userid'], github_username=fellows[fellow]['github_username'],
project=fellows[fellow]['project'], id=item['id'], url=item['html_url'], activity_type="Pull Request", message=item['title'],
number=item['number'], created_at=item['created_at'], closed_at=item['closed_at'], merged_at=item['pull_request']['merged_at'])

# Check Issue is in the project
elif "pull_request" not in item:
helpers.add_to_db(email=fellow, github_id=fellows[fellow]['github_userid'], github_username=fellows[fellow]['github_username'],
project=fellows[fellow]['project'], id=item['id'], url=item['html_url'], activity_type="Issue", message=item['title'],
number=item['number'], created_at=item['created_at'], closed_at=item['closed_at'])
else:
print("Date not within batch")
else:
print(response)

Expand Down
9 changes: 4 additions & 5 deletions orientation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def collect_orientation_data(fellows, projects):
for project in projects:

# PRs
print("Collecting PRs and Issues....")
issues_response = git_metrics.make_gh_request(git_metrics.ISSUES_URL, fellows[fellow]['github_username'])
if issues_response != None and "items" in issues_response:
print("Collecting PRs and Issues....")
for item in issues_response["items"]:
url = '/'.join(item['html_url'].split('/')[:5])
# Check PR is in the project
Expand Down Expand Up @@ -81,8 +81,9 @@ def collect_orientation_data(fellows, projects):
helpers.standardize_datetime(item['created_at'], "Issue"),
helpers.standardize_datetime(item['closed_at'], "Issue"),
"Null"])

time.sleep(15)
time.sleep(10)
else:
print("No PRs/Issues fetched")

# Commits
print("Collecting commits....")
Expand Down Expand Up @@ -146,8 +147,6 @@ def check_no_duplicates(url, id, closed_date="Null", merged_date="Null"):
date = helpers.standardize_datetime(merged_date, "Pull Request")
orientation_data.update_acell(f"L{row + 2}", date)
get_pr_changed_lines(url, row)
time.sleep(5)

return False
return True

Expand Down

0 comments on commit cf329cb

Please sign in to comment.