mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd/database): track user status changes over time (#16019)
RE: https://github.com/coder/coder/issues/15740, https://github.com/coder/coder/issues/15297 In order to add a graph to the coder frontend to show user status over time as an indicator of license usage, this PR adds the following: * a new `api.insightsUserStatusCountsOverTime` endpoint to the API * which calls a new `GetUserStatusCountsOverTime` query from postgres * which relies on two new tables `user_status_changes` and `user_deleted` * which are populated by a new trigger and function that tracks updates to the users table The chart itself will be added in a subsequent PR --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
co-authored by
Mathias Fredriksson
parent
73d8dde6ed
commit
4543b21b7c
Generated
+50
@@ -260,3 +260,53 @@ curl -X GET http://coder-server:8080/api/v2/insights/user-latency?start_time=201
|
||||
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.UserLatencyInsightsResponse](schemas.md#codersdkuserlatencyinsightsresponse) |
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
## Get insights about user status counts
|
||||
|
||||
### Code samples
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/insights/user-status-counts?tz_offset=0 \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /insights/user-status-counts`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | In | Type | Required | Description |
|
||||
|-------------|-------|---------|----------|----------------------------|
|
||||
| `tz_offset` | query | integer | true | Time-zone offset (e.g. -2) |
|
||||
|
||||
### Example responses
|
||||
|
||||
> 200 Response
|
||||
|
||||
```json
|
||||
{
|
||||
"status_counts": {
|
||||
"property1": [
|
||||
{
|
||||
"count": 10,
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
}
|
||||
],
|
||||
"property2": [
|
||||
{
|
||||
"count": 10,
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
| Status | Meaning | Description | Schema |
|
||||
|--------|---------------------------------------------------------|-------------|----------------------------------------------------------------------------------------|
|
||||
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.GetUserStatusCountsResponse](schemas.md#codersdkgetuserstatuscountsresponse) |
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
Generated
+44
@@ -3000,6 +3000,34 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
|
||||
|-------|--------|----------|--------------|-------------|
|
||||
| `key` | string | false | | |
|
||||
|
||||
## codersdk.GetUserStatusCountsResponse
|
||||
|
||||
```json
|
||||
{
|
||||
"status_counts": {
|
||||
"property1": [
|
||||
{
|
||||
"count": 10,
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
}
|
||||
],
|
||||
"property2": [
|
||||
{
|
||||
"count": 10,
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|--------------------|---------------------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `status_counts` | object | false | | |
|
||||
| » `[any property]` | array of [codersdk.UserStatusChangeCount](#codersdkuserstatuschangecount) | false | | |
|
||||
|
||||
## codersdk.GetUsersResponse
|
||||
|
||||
```json
|
||||
@@ -6724,6 +6752,22 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
| `dormant` |
|
||||
| `suspended` |
|
||||
|
||||
## codersdk.UserStatusChangeCount
|
||||
|
||||
```json
|
||||
{
|
||||
"count": 10,
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------|---------|----------|--------------|-------------|
|
||||
| `count` | integer | false | | |
|
||||
| `date` | string | false | | |
|
||||
|
||||
## codersdk.ValidateUserPasswordRequest
|
||||
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user