Skip to content

Commit

Permalink
Collect commits using API as well as CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
wrussell1999 committed Mar 4, 2024
1 parent 045f056 commit 777f2af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
11 changes: 6 additions & 5 deletions git_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,23 @@ def __init__(self, term):
self.scope = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']
self.credentials = ServiceAccountCredentials.from_json_keyfile_name("gs_credentials.json", self.scope)
self.client = gspread.authorize(self.credentials)

self.sheet = self.client.open_by_url("https://docs.google.com/spreadsheets/d/12quNi2TYuRK40woals-ABPT5NcsmhBmC_dHNU9rX1Do")
self.activities_data_sh = self.sheet.worksheet("activities_data")
self.utc = pytz.utc

self.utc = pytz.utc
dates_sh = self.sheet.worksheet('Fellowship Terms')
for row in dates_sh.get_all_records():

if str(row['Dot_Notation__c']).strip() == term:
start_date = str(row['Start_Date__c']).split('-')
end_date = str(row['End_Date__c']).split('-')


self.program_date_start_year = int(start_date[0])
self.program_date_end_year = int(end_date[0])
self.program_date_start_month = int(start_date[1])
self.program_date_end_month = int(end_date[1])
self.program_date_start_day = int(start_date[2])
self.program_date_end_day = int(end_date[2])

self.batch_start = datetime.datetime(self.program_date_start_year, self.program_date_start_month, self.program_date_start_day)
self.batch_end = datetime.datetime(self.program_date_end_year, self.program_date_end_month, self.program_date_end_day)

Expand All @@ -69,7 +66,6 @@ def collect_data(self):
if len(fellow_projects['urls']) < 1:
print(f"No URLs for {self.fellows[fellow]['project']}. Skipping")
continue


# Getting PRs/Issues
issues_response = self.make_gh_request(self.ISSUES_URL, self.fellows[fellow]['github_username'])
Expand All @@ -89,6 +85,11 @@ def collect_data(self):
if len(row) > 0:
self.project_data.append(row)

# Run commit check again using API for commits not collected using email. Using GitHub username to collect onwards
commits_response = self.make_gh_request(self.COMMITS_URL, self.fellows[fellow]['github_username'])
if commits_response != None and "items" in commits_response:
self.find_commits(commits_response, fellow_projects['urls'], fellow)

# Getting Issues
for url in fellow_projects['urls']:
if "https://github" in url:
Expand Down
21 changes: 21 additions & 0 deletions orientation_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ def collect_data(self):
"Null",
"Null"])

# Get commits via API to fill in any blanks
commits_response = self.make_gh_request(self.COMMITS_URL, self.fellows[fellow]['github_username'])
if commits_response != None and "items" in commits_response:
for item in commits_response['items']:
url = item['repository']['html_url']
if url in self.projects:
if self.check_no_duplicates(url, item['sha']):
print(f"Adding to db - {url}")
self.project_data.append([fellow,
self.fellows[fellow]['term'],
self.fellows[fellow]['pod'],
self.fellows[fellow]['github_username'],
item['sha'],
url,
"Commit",
item['commit']['message'],
"Null",
helpers.standardize_datetime(issue['created_at'], "Commit"),
"Null",
"Null"])

# Issues
for url in self.projects[project]['urls']:
if "https://github" in url:
Expand Down

0 comments on commit 777f2af

Please sign in to comment.