32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
import requests
|
|
import datetime as dt
|
|
|
|
def main(vcs, begin_date):
|
|
gha_info = {}
|
|
#this is the entire list of Github 'milestones' grabbed from the API
|
|
gha_info['milestones'] = get_milestone_information(vcs)
|
|
#this is the count of milestones that occur after the cutoff date
|
|
gha_info['milestone_count'] = parse_milestones(gha_info['milestones'], begin_date)
|
|
return gha_info
|
|
|
|
#this simple API call has been working for now but may need to be updated as more information is desired
|
|
def get_milestone_information(vcs_path):
|
|
repo_uri=vcs_path[0]
|
|
repo_uri_list = repo_uri.split('/')
|
|
api_url = "https://api.github.com/repos/" + repo_uri_list[-2] + "/" + repo_uri_list[-1] + "/milestones"
|
|
response = requests.get(api_url)
|
|
response_dict = response.json()
|
|
return response_dict
|
|
|
|
def parse_milestones(milestones, earliest_date):
|
|
count_of_milestones = 0
|
|
for entry in milestones:
|
|
#if entry date is more recent than the earliest date we're looking at
|
|
if dt.datetime.fromisoformat(entry['created_at'][:-1]) > earliest_date:
|
|
count_of_milestones += 1
|
|
return count_of_milestones
|
|
|
|
|
|
if __name__ == "__main__":
|
|
vcs = ['https://github.com/fabiangreffrath/woof']
|
|
main(vcs) |