Testaustime / testaustime-backend

https://api.testaustime.fi
MIT License
12 stars 11 forks source link

Documentation incorrect for `GET /users/{username}/activity/current` #101

Open Eldemarkki opened 10 months ago

Eldemarkki commented 10 months ago

The documentation specifies that the GET request to /users/{username}/activity/current always specifies that the started field is in UTC time (by including the Z at the end):

{
    "started": "YYYY-MM-DDTHH:MM:SS.ssssssZ",
    "duration": "10",
    "heartbeat": {
        "language": "c",
        "hostname": "hostname1",
        "editor_name": "Neovim",
        "project_name": "cool_project22"
    }
}

However, in reality that "Z" is not included. Here is an example response that I got:

{
  "started": "2023-12-17T12:03:20.938417739",
  "duration": 240,
  "heartbeat": {
    "project_name": "testaustime-frontend",
    "language": "typescript",
    "editor_name": "vscode",
    "hostname": "ideapad"
  }
}

I believe the same problem exists for all other timestamps that are returned from any endpoint. We already have an issue in the frontend for this, but I think it would be best to fix in the backend.

Also, it seems that the duration field is a number instead of a string.

lajp commented 10 months ago

The easiest thing would be just to use DateTimes that include a timezone (most likely just UTC). This could be achieved with minor database refactoring.