From fb7e26c88dea48ba02da9449fe7d964c8e0c6571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=98=E5=BF=A7=E5=8C=97=E8=90=B1=E8=8D=89?= Date: Wed, 18 Sep 2024 17:05:18 +0800 Subject: [PATCH 1/2] feat: custom wakatime api url --- README.md | 2 ++ action.yml | 5 +++++ sources/manager_download.py | 4 ++-- sources/manager_environment.py | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31da994a..4f6a4837 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,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://your-own-wakapi.dev/api/` + `SYMBOL_VERSION` flag can be set symbol for progress bar (default: `1`) | Version | Done block | Empty block | |-------- | ---------- | ----------- | diff --git a/action.yml b/action.yml index 8a413d84..1b5ec367 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,11 @@ inputs: WAKATIME_API_KEY: description: 'Your Wakatime API Key' required: true + + WAKATIME_API_URL: + description: 'Wakatime API URL' + required: false + default: "https://wakatime.com/api/" SECTION_NAME: description: 'Name used in readme to scope the updated section' diff --git a/sources/manager_download.py b/sources/manager_download.py index dddd5677..e005ad5c 100644 --- a/sources/manager_download.py +++ b/sources/manager_download.py @@ -123,8 +123,8 @@ async def init_download_manager(user_login: str): """ await DownloadManager.load_remote_resources( linguist="https://cdn.jsdelivr.net/gh/github/linguist@master/lib/linguist/languages.yml", - waka_latest=f"https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key={EM.WAKATIME_API_KEY}", - waka_all=f"https://wakatime.com/api/v1/users/current/all_time_since_today?api_key={EM.WAKATIME_API_KEY}", + waka_latest=f"{EM.WAKATIME_API_URL}/v1/users/current/stats/last_7_days?api_key={EM.WAKATIME_API_KEY}", + waka_all=f"{EM.WAKATIME_API_URL}/v1/users/current/all_time_since_today?api_key={EM.WAKATIME_API_KEY}", github_stats=f"https://github-contributions.vercel.app/api/v1/{user_login}", ) diff --git a/sources/manager_environment.py b/sources/manager_environment.py index 33bbee44..976bb6da 100644 --- a/sources/manager_environment.py +++ b/sources/manager_environment.py @@ -15,6 +15,9 @@ class EnvironmentManager: GH_TOKEN = environ["INPUT_GH_TOKEN"] WAKATIME_API_KEY = environ["INPUT_WAKATIME_API_KEY"] + WAKATIME_API_URL = getenv("INPUT_WAKATIME_API_URL", "https://wakatime.com/api/") + if not WAKATIME_API_URL.endswith("/"): + WAKATIME_API_URL += "/" SECTION_NAME = getenv("INPUT_SECTION_NAME", "waka") PULL_BRANCH_NAME = getenv("INPUT_PULL_BRANCH_NAME", "") From 06e26615f0f635a7ecaef9dcd298016919805b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=98=E5=BF=A7=E5=8C=97=E8=90=B1=E8=8D=89?= Date: Wed, 18 Sep 2024 17:08:45 +0800 Subject: [PATCH 2/2] fix: slash in url --- sources/manager_download.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/manager_download.py b/sources/manager_download.py index e005ad5c..54a5ec21 100644 --- a/sources/manager_download.py +++ b/sources/manager_download.py @@ -123,8 +123,8 @@ async def init_download_manager(user_login: str): """ await DownloadManager.load_remote_resources( linguist="https://cdn.jsdelivr.net/gh/github/linguist@master/lib/linguist/languages.yml", - waka_latest=f"{EM.WAKATIME_API_URL}/v1/users/current/stats/last_7_days?api_key={EM.WAKATIME_API_KEY}", - waka_all=f"{EM.WAKATIME_API_URL}/v1/users/current/all_time_since_today?api_key={EM.WAKATIME_API_KEY}", + waka_latest=f"{EM.WAKATIME_API_URL}v1/users/current/stats/last_7_days?api_key={EM.WAKATIME_API_KEY}", + waka_all=f"{EM.WAKATIME_API_URL}v1/users/current/all_time_since_today?api_key={EM.WAKATIME_API_KEY}", github_stats=f"https://github-contributions.vercel.app/api/v1/{user_login}", )