FIX: Fixes #30

This commit is contained in:
Anmol
2020-08-04 21:34:51 +05:30
parent 9c0fdc6ac1
commit 23206dc760

View File

@@ -295,17 +295,21 @@ def get_waka_time_stats():
print("Error With WAKA time API returned " + str(request.status_code) + " Response " + str(request.json())) print("Error With WAKA time API returned " + str(request.status_code) + " Response " + str(request.json()))
else: else:
empty = True
data = request.json() data = request.json()
if showCommit.lower() in ['true', '1', 't', 'y', 'yes']: if showCommit.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
stats = stats + generate_commit_list(tz=data['data']['timezone']) + '\n\n' stats = stats + generate_commit_list(tz=data['data']['timezone']) + '\n\n'
stats += '📊 **This week I spent my time on** \n\n' stats += '📊 **This week I spent my time on** \n\n'
stats += '```text\n' stats += '```text\n'
if showTimeZone.lower() in ['true', '1', 't', 'y', 'yes']: if showTimeZone.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
tzone = data['data']['timezone'] tzone = data['data']['timezone']
stats = stats + '⌚︎ Timezone: ' + tzone + '\n\n' stats = stats + '⌚︎ Timezone: ' + tzone + '\n\n'
if showLanguage.lower() in ['true', '1', 't', 'y', 'yes']: if showLanguage.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
if len(data['data']['languages']) == 0: if len(data['data']['languages']) == 0:
lang_list = "No Activity tracked this Week" lang_list = "No Activity tracked this Week"
else: else:
@@ -313,6 +317,7 @@ def get_waka_time_stats():
stats = stats + '💬 Languages: \n' + lang_list + '\n\n' stats = stats + '💬 Languages: \n' + lang_list + '\n\n'
if showEditors.lower() in ['true', '1', 't', 'y', 'yes']: if showEditors.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
if len(data['data']['editors']) == 0: if len(data['data']['editors']) == 0:
edit_list = "No Activity tracked this Week" edit_list = "No Activity tracked this Week"
else: else:
@@ -320,6 +325,7 @@ def get_waka_time_stats():
stats = stats + '🔥 Editors: \n' + edit_list + '\n\n' stats = stats + '🔥 Editors: \n' + edit_list + '\n\n'
if showProjects.lower() in ['true', '1', 't', 'y', 'yes']: if showProjects.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
if len(data['data']['projects']) == 0: if len(data['data']['projects']) == 0:
project_list = "No Activity tracked this Week" project_list = "No Activity tracked this Week"
else: else:
@@ -327,6 +333,7 @@ def get_waka_time_stats():
stats = stats + '🐱‍💻 Projects: \n' + project_list + '\n\n' stats = stats + '🐱‍💻 Projects: \n' + project_list + '\n\n'
if showOs.lower() in ['true', '1', 't', 'y', 'yes']: if showOs.lower() in ['true', '1', 't', 'y', 'yes']:
empty = False
if len(data['data']['operating_systems']) == 0: if len(data['data']['operating_systems']) == 0:
os_list = "No Activity tracked this Week" os_list = "No Activity tracked this Week"
else: else:
@@ -334,6 +341,8 @@ def get_waka_time_stats():
stats = stats + '💻 Operating Systems: \n' + os_list + '\n\n' stats = stats + '💻 Operating Systems: \n' + os_list + '\n\n'
stats += '```\n\n' stats += '```\n\n'
if empty:
return ""
return stats return stats