Added Code time badge

FIX #230
This commit is contained in:
anmol098
2021-12-01 18:34:16 +05:30
parent 64be4f90fc
commit a58dd10faf
2 changed files with 18 additions and 0 deletions

View File

@@ -97,6 +97,11 @@ inputs:
description: "Show updated date"
default: "True"
SHOW_TOTAL_CODE_TIME:
required: false
description: "Show Total Time you have coded"
default: "True"
runs:
using: 'docker'
image: 'Dockerfile'

13
main.py
View File

@@ -47,6 +47,7 @@ commit_by_me = os.getenv('INPUT_COMMIT_BY_ME')
ignored_repos_name = str(os.getenv('INPUT_IGNORED_REPOS') or '').replace(' ', '').split(',')
show_updated_date = os.getenv('INPUT_SHOW_UPDATED_DATE')
commit_message = os.getenv('INPUT_COMMIT_MESSAGE')
show_total_code_time = os.getenv('INPUT_SHOW_TOTAL_CODE_TIME')
show_waka_stats = 'y'
# The GraphQL query to get commit data.
userInfoQuery = """
@@ -150,6 +151,7 @@ repositoryListQuery = Template("""
}
""")
def millify(n):
millnames = ['', ' Thousand', ' Million', ' Billion', ' Trillion']
n = float(n)
@@ -462,6 +464,17 @@ def get_stats(github):
# This condition is written to calculate the lines of code because it is heavy process soo needs to be calculate once this will reduce the execution time
yearly_data = get_yearly_data()
if show_total_code_time.lower() in truthy:
request = requests.get(
f"https://wakatime.com/api/v1/users/current/all_time_since_today?api_key={waka_key}")
if request.status_code == 401:
print("Error With WAKA time API returned " + str(request.status_code) + " Response " + str(request.json()))
else:
data = request.json()
stats += '![Code Time](http://img.shields.io/badge/' + quote(
str("Code Time")) + '-' + quote(str(
data['data']['text'])) + '-blue)\n\n'
if show_profile_view.lower() in truthy:
data = run_v3_api(get_profile_view.substitute(owner=username, repo=username))
stats += '![Profile Views](http://img.shields.io/badge/' + quote(str(translate['Profile Views'])) + '-' + str(