Merge pull request #4 from anmol098/dev

Fixed Commit Stats
This commit is contained in:
Anmol Pratap Singh
2020-07-22 11:05:07 +05:30
committed by GitHub

32
main.py
View File

@@ -124,18 +124,21 @@ def generate_commit_list():
for repository in repos: for repository in repos:
result = run_query( result = run_query(
createCommittedDateQuery.substitute(owner=repository["owner"]["login"], name=repository["name"], id=id)) createCommittedDateQuery.substitute(owner=repository["owner"]["login"], name=repository["name"], id=id))
committed_dates = result["data"]["repository"]["ref"]["target"]["history"]["edges"] try:
for committedDate in committed_dates: committed_dates = result["data"]["repository"]["ref"]["target"]["history"]["edges"]
date = datetime.datetime.strptime(committedDate["node"]["committedDate"], "%Y-%m-%dT%H:%M:%SZ") for committedDate in committed_dates:
hour = date.hour date = datetime.datetime.strptime(committedDate["node"]["committedDate"], "%Y-%m-%dT%H:%M:%SZ")
if 6 <= hour < 12: hour = date.hour
morning += 1 if 6 <= hour < 12:
if 12 <= hour < 18: morning += 1
daytime += 1 if 12 <= hour < 18:
if 18 <= hour < 24: daytime += 1
evening += 1 if 18 <= hour < 24:
if 0 <= hour < 6: evening += 1
night += 1 if 0 <= hour < 6:
night += 1
except Exception as ex:
print("Exception occured" + str(ex));
sumAll = morning + daytime + evening + night sumAll = morning + daytime + evening + night
if morning + daytime >= evening + night: if morning + daytime >= evening + night:
@@ -157,10 +160,7 @@ def get_stats():
stats = '' stats = ''
if showCommit.lower() in ['true', '1', 't', 'y', 'yes']: if showCommit.lower() in ['true', '1', 't', 'y', 'yes']:
try: stats = stats + generate_commit_list() + '\n\n'
stats = stats + generate_commit_list() + '\n\n'
except Exception as ex:
print("GitHub Personal access token not configured properly or invalid" + str(ex))
try: try:
request = requests.get( request = requests.get(