wakatime / vscode-wakatime

Visual Studio Code plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/vs-code
BSD 3-Clause "New" or "Revised" License
1.2k stars 133 forks source link

Can't not access stats correctly by api provided #345

Closed AmosChenYQ closed 1 year ago

AmosChenYQ commented 1 year ago

I can get my coding stats of last 7 days in wakatime website dashboard, but when I tried to use github actions by accessing https://wakatime.com/api/v1/users/amoschenyq/stats/last_7_days?api_key=My_WAKA_Secret_API_Key it returned empty stats like this:

{"data":{"best_day":null,"categories":[],"created_at":"2023-04-27T04:24:20Z","daily_average":0.0,"daily_average_including_other_language":0.0,"days_including_holidays":7,"days_minus_holidays":0,"dependencies":[],"editors":[],"end":"2023-04-26T15:59:59Z","holidays":7,"human_readable_daily_average":"0 secs","human_readable_daily_average_including_other_language":"0 secs","human_readable_range":"last week","human_readable_total":"0 secs","human_readable_total_including_other_language":"0 secs","id":"2eb1cb26-a189-4bca-b48d-c01113a67a07","is_already_updating":false,"is_coding_activity_visible":true,"is_including_today":false,"is_other_usage_visible":true,"is_stuck":false,"is_up_to_date":true,"is_up_to_date_pending_future":false,"languages":[],"machines":[],"modified_at":"2023-04-27T04:24:20Z","operating_systems":[],"percent_calculated":100,"projects":[],"range":"last_7_days","start":"2023-04-19T16:00:00Z","status":"ok","timeout":5,"timezone":"Asia/Shanghai","total_seconds":0.0,"total_seconds_including_other_language":0.0,"user_id":"0dadc195-2ae1-4bf8-b34e-0fed133e935a","username":"AmosChenYQ","writes_only":false}}

It seemed that this API can not access my stats correctly. And I tired some other APIs like this https://wakatime.com/developers#status_bar with this https://wakatime.com/api/v1/users/amoschenyq/status_bar/today?api_key=My_WAKA_Secret_API_Key it can return right result

Is it that my use of this API is wrong or something I forget to set in somewhere?(BTW, I have set my Display code time publicly and Display languages, editors, os, categories publicly)

alanhamlett commented 1 year ago

Check that the time range returned is the same as the range you're using on your dashboard. By default, those api endpoints don't return data for Today. For ex: last_7_days is equal to dashboard range Last 7 Days from Yesterday.

AmosChenYQ commented 1 year ago

Thanks for your rely, after two days, now I can get the data I need