mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00: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:
42
coderd/database/migrations/testdata/fixtures/000283_user_status_changes.up.sql
vendored
Normal file
42
coderd/database/migrations/testdata/fixtures/000283_user_status_changes.up.sql
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
INSERT INTO
|
||||
users (
|
||||
id,
|
||||
email,
|
||||
username,
|
||||
hashed_password,
|
||||
created_at,
|
||||
updated_at,
|
||||
status,
|
||||
rbac_roles,
|
||||
login_type,
|
||||
avatar_url,
|
||||
last_seen_at,
|
||||
quiet_hours_schedule,
|
||||
theme_preference,
|
||||
name,
|
||||
github_com_user_id,
|
||||
hashed_one_time_passcode,
|
||||
one_time_passcode_expires_at
|
||||
)
|
||||
VALUES (
|
||||
'5755e622-fadd-44ca-98da-5df070491844', -- uuid
|
||||
'test@example.com',
|
||||
'testuser',
|
||||
'hashed_password',
|
||||
'2024-01-01 00:00:00',
|
||||
'2024-01-01 00:00:00',
|
||||
'active',
|
||||
'{}',
|
||||
'password',
|
||||
'',
|
||||
'2024-01-01 00:00:00',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
123,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
UPDATE users SET status = 'dormant', updated_at = '2024-01-01 01:00:00' WHERE id = '5755e622-fadd-44ca-98da-5df070491844';
|
||||
UPDATE users SET deleted = true, updated_at = '2024-01-01 02:00:00' WHERE id = '5755e622-fadd-44ca-98da-5df070491844';
|
Reference in New Issue
Block a user