Skip to content

Commit

Permalink
implements anmol098#220
Browse files Browse the repository at this point in the history
  • Loading branch information
MeerBiene committed Jan 15, 2022
1 parent c4738ce commit 325e5aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ CSS 2 repos █░░░░░░░░░░░░░░░░

`IGNORED_REPOS` flag can be set to `"waka-readme-stats, my-first-repo"` (just an example) to ignore some repos you don’t want to be counted

`WAKATIME_API_URL` flag can be set if you are hosting your own wakatime compliant backend like [wakapi](https://github.com/muety/wakapi). You only have to supply your base url like so `https://wakapi.dev`

**Timeline**

![Chart not found](https://raw.githubusercontent.com/anmol098/anmol098/master/charts/bar_graph.png)
Expand Down
8 changes: 5 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
listReg = f"{START_COMMENT}[\\s\\S]+{END_COMMENT}"

waka_key = os.getenv('INPUT_WAKATIME_API_KEY')
waka_url = os.getenv('INPUT_WAKATIME_URL', "https://wakatime.com")
ghtoken = os.getenv('INPUT_GH_TOKEN')
showTimeZone = os.getenv('INPUT_SHOW_TIMEZONE')
showProjects = os.getenv('INPUT_SHOW_PROJECTS')
Expand Down Expand Up @@ -98,7 +99,7 @@
get_profile_traffic = Template("""/repos/$owner/$repo/traffic/popular/referrers""")
truthy = ['true', '1', 't', 'y', 'yes']


exit()
def run_v3_api(query):
request = requests.get('https://api.github.com' + query, headers=headers)
if request.status_code == 200:
Expand Down Expand Up @@ -309,7 +310,7 @@ def generate_commit_list(tz):
def get_waka_time_stats():
stats = ''
request = requests.get(
f"https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key={waka_key}")
f"https://{waka_url}/api/v1/users/current/stats/last_7_days?api_key={waka_key}")
no_activity = translate["No Activity Tracked This Week"]

if request.status_code == 401:
Expand Down Expand Up @@ -468,8 +469,9 @@ def get_stats(github):
yearly_data = get_yearly_data()

if show_total_code_time.lower() in truthy:
actual_base_url = f"{waka_url}/api/" if "wakatime.com" in waka_url else f"{waka_url}/api/compat/wakatime/"
request = requests.get(
f"https://wakatime.com/api/v1/users/current/all_time_since_today?api_key={waka_key}")
f"https://{actual_base_url}/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()))
elif "text" not in request.json()["data"]:
Expand Down

0 comments on commit 325e5aa

Please sign in to comment.