Skip to content

Commit

Permalink
Auto run orientation data
Browse files Browse the repository at this point in the history
  • Loading branch information
wrussell1999 committed Jan 25, 2024
1 parent d14e3d5 commit 51e4f67
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
22 changes: 7 additions & 15 deletions git_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytz
import os
import helpers
import orientation_data
import gspread
import cli
from oauth2client.service_account import ServiceAccountCredentials
Expand Down Expand Up @@ -34,20 +35,6 @@
ISSUES_URL = "issues?q=author:"
ISSUE_URL = "issues?assignee"


program_date_format = "%Y-%m-%d"

def get_terms():
dates_sh = sheet.worksheet('Fellowship Terms')

terms = []
for row in dates_sh.get_all_records():
now = datetime.datetime.now()

if datetime.datetime.strptime(str(row['Start_Date__c']).strip(), program_date_format) <= now and datetime.datetime.strptime(str(row['End_Date__c']).strip(), program_date_format) >= now:
terms.append(str(row['Dot_Notation__c']).strip())
return terms

def setup_dates(term):
dates_sh = sheet.worksheet('Fellowship Terms')

Expand Down Expand Up @@ -250,7 +237,7 @@ def find_gl_commits(response, fellow):


if __name__ == "__main__":
terms = get_terms()
terms = helpers.get_terms()
print(f"Collecting data for {str(terms)}")
for term in terms:
fellows.clear()
Expand All @@ -260,5 +247,10 @@ def find_gl_commits(response, fellow):
projects = helpers.get_projects(term)
collect_data()
print(f"{term} Completed")
time.sleep(30)
if datetime.datetime.now() < batch_start.timedelta(days=21):
print(f"Collecting Orientation Data for {term}")
orientation_data.collect_data(term)
print(f"Orientation Data completed for {term}")
else:
print(f"Error with dates in Salesforce for {term}")
14 changes: 14 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
client = gspread.authorize(credentials)
sheet = client.open_by_url("https://docs.google.com/spreadsheets/d/12quNi2TYuRK40woals-ABPT5NcsmhBmC_dHNU9rX1Do")

program_date_format = "%Y-%m-%d"


def get_terms():
dates_sh = sheet.worksheet('Fellowship Terms')

terms = []
for row in dates_sh.get_all_records():
now = datetime.datetime.now()

if datetime.datetime.strptime(str(row['Start_Date__c']).strip(), program_date_format) <= now and datetime.datetime.strptime(str(row['End_Date__c']).strip(), program_date_format) >= now:
terms.append(str(row['Dot_Notation__c']).strip())
return terms

def get_fellows(term):
fellows = {}
fellows_sh = sheet.worksheet("Enrolled Fellows")
Expand Down
4 changes: 1 addition & 3 deletions orientation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def get_pr_changed_lines(url, row):
orientation_data.update_acell(f"N{row + 2}", pull_response['deletions'])
orientation_data.update_acell(f"O{row + 2}", pull_response['changed_files'])

if __name__ == "__main__":
term = "23.FAL.B"
def collect_data(term):
fellows = helpers.get_fellows(term)
get_orientation_projects(term)
collect_orientation_data()
print(f"Orientation Data Completed for {term}")

0 comments on commit 51e4f67

Please sign in to comment.