Testaustime / testaustime-backend

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

feat: show current heartbeat in friend list and when adding a friend #67

Closed Eldemarkki closed 1 year ago

Eldemarkki commented 1 year ago

This PR adds a status field to the response of GET /friends/list and POST /friends/add showing the current heartbeat status of that friend.

Getting the current heartbeat could be refactored into its own function, but I wasn't sure where to place that so I just copy-pasted it.

Example responses: POST /friends/add:

{
  "username": "testuser2",
  "coding_time": {
    "all_time": 0,
    "past_month": 0,
    "past_week": 0
  },
  "status": {
    "started": "2023-02-21T00:52:56.083467079",
    "duration": 5,
    "heartbeat": {
      "project_name": null,
      "language": null,
      "editor_name": null,
      "hostname": null
    }
  }
}

GET /friends/list:

[
  {
    "username": "testuser2",
    "coding_time": {
      "all_time": 0,
      "past_month": 0,
      "past_week": 0
    },
    "status": {
      "started": "2023-02-21T01:03:04.610385534",
      "duration": 3,
      "heartbeat": {
        "project_name": null,
        "language": null,
        "editor_name": null,
        "hostname": null
      }
    }
  }
]
DrVilepis commented 1 year ago

Also please update the documentation.