muety / wakapi

📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
https://wakapi.dev
MIT License
2.75k stars 171 forks source link

Null in the response from api #399

Closed mootfrost closed 2 years ago

mootfrost commented 2 years ago

I installed wakapi on postgres a week ago, I want to get data from the api on the site, but the request https://waka.mootfrost.ru/api/compat/wakatime/v1/users/Mootfrost/stats/yesterday returns:

{
  "data": {
    "username": "Mootfrost",
    "user_id": "Mootfrost",
    "start": "2022-08-28T21:00:08.99Z",
    "end": "2022-08-29T20:41:36.804Z",
    "total_seconds": 21741,
    "daily_average": 0,
    "days_including_holidays": 0,
    "editors": null,
    "languages": null,
    "machines": null,
    "projects": null,
    "operating_systems": null
  }
}

I thought that the data for the required period was not updated, but this has been happening for a week and there is data in dashboard

muety commented 2 years ago

Weird, because it has a non-zero value for total_seconds. Can you check the content of heartbeats and summaries tables in your database?

mootfrost commented 2 years ago

Weird, because it has a non-zero value for total_seconds. Can you check the content of heartbeats and summaries tables in your database?

There is rows in heartbeats and summaries:

Screenshot_20220830_210326 Screenshot_20220830_210340

muety commented 2 years ago

Are there heartbeats and summaries whose time matches the requested range, i.e. yesterday in your case? And can you please try to run with ?recompute=true. Also, please see if there are any errors in the logs.

mootfrost commented 2 years ago

Are there heartbeats and summaries whose time matches the requested range, i.e. yesterday in your case? And can you please try to run with ?recompute=true. Also, please see if there are any errors in the logs.

There was a 'role postgres does not exist' error in the database, I tried a solution from the Internet and now I can't even log in to my account, although the database is available and has not been deleted...

muety commented 2 years ago

On localhost (of where the Postgres instance is running) you can usually connect without credentials (using psql command-line tool). Maybe try to entirely drop the old user, create a new one, reassign the Wakapi database to the new user and try again. Alternatively, dump the Wakapi database (using pg_dump), entirely delete it, create a whole fresh one and import your old data using pg_restore.

Something seems to be messed up with your database. Never came across that error before, though. Can you actually post the exact error message?

mootfrost commented 1 year ago

For anyone who will face this problem. By default, ALL DATA FOR ALL TIME IS private. You need to allow access in the permissions section. I'm so dumb...