Merge pull request #8 from joe733/master

fix: Changed to week streak instead for week of the year
This commit is contained in:
Athul Cyriac Ajay 2020-07-18 09:40:51 +05:30 committed by GitHub
commit 96f680b05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
main.py
View File

@ -19,12 +19,10 @@ waka_key = os.getenv('INPUT_WAKATIME_API_KEY')
ghtoken = os.getenv('INPUT_GH_TOKEN')
def this_week():
'''Returns current week span'''
week_number = datetime.date.today().isocalendar()[1]
month = datetime.date.today().strftime('%B')
week_start = datetime.datetime.today().day - datetime.datetime.today().weekday()
week_end = week_start + 5
return f"Week #{week_number} : {month} {week_start} - {week_end}"
'''Returns a week's streak'''
week_end = datetime.datetime.today() - datetime.timedelta(days=1)
week_start = week_end - datetime.timedelta(days=7)
return f"Week: {week_start.strftime('%d %B, %Y')} - {week_end.strftime('%d %B, %Y')}"
def make_graph(percent: float):
'''Make progress graph from API graph'''
@ -43,7 +41,7 @@ def get_stats():
for l in lang_data[:5]:
ln = len(l['name'])
ln_text = len(l['text'])
op = f"{l['name']}{' '*(12-ln)}{l['text']}{' '*(20-ln_text)}{make_graph(l['percent'])} {l['percent']}%"
op = f"{l['name']}{' '*(12-ln)}{l['text']}{' '*(20-ln_text)}{make_graph(l['percent'])} {l['percent']} %"
data_list.append(op)
data = ' \n'.join(data_list)
return '```text\n'+this_week()+'\n\n'+data+'\n```'