mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
@@ -0,0 +1 @@
|
||||
DROP TABLE workspace_app_stats;
|
||||
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE workspace_app_stats (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id uuid NOT NULL REFERENCES users (id),
|
||||
workspace_id uuid NOT NULL REFERENCES workspaces (id),
|
||||
agent_id uuid NOT NULL REFERENCES workspace_agents (id),
|
||||
access_method text NOT NULL,
|
||||
slug_or_port text NOT NULL,
|
||||
session_id uuid NOT NULL,
|
||||
session_started_at timestamptz NOT NULL,
|
||||
session_ended_at timestamptz NOT NULL,
|
||||
requests integer NOT NULL,
|
||||
|
||||
-- Set a unique constraint to allow upserting the session_ended_at
|
||||
-- and requests fields without risk of collisions.
|
||||
UNIQUE(user_id, agent_id, session_id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE workspace_app_stats IS 'A record of workspace app usage statistics';
|
||||
|
||||
COMMENT ON COLUMN workspace_app_stats.id IS 'The ID of the record';
|
||||
COMMENT ON COLUMN workspace_app_stats.user_id IS 'The user who used the workspace app';
|
||||
COMMENT ON COLUMN workspace_app_stats.workspace_id IS 'The workspace that the workspace app was used in';
|
||||
COMMENT ON COLUMN workspace_app_stats.agent_id IS 'The workspace agent that was used';
|
||||
COMMENT ON COLUMN workspace_app_stats.access_method IS 'The method used to access the workspace app';
|
||||
COMMENT ON COLUMN workspace_app_stats.slug_or_port IS 'The slug or port used to to identify the app';
|
||||
COMMENT ON COLUMN workspace_app_stats.session_id IS 'The unique identifier for the session';
|
||||
COMMENT ON COLUMN workspace_app_stats.session_started_at IS 'The time the session started';
|
||||
COMMENT ON COLUMN workspace_app_stats.session_ended_at IS 'The time the session ended';
|
||||
COMMENT ON COLUMN workspace_app_stats.requests IS 'The number of requests made during the session, a number larger than 1 indicates that multiple sessions were rolled up into one';
|
||||
|
||||
-- Create index on workspace_id for joining/filtering by templates.
|
||||
CREATE INDEX workspace_app_stats_workspace_id_idx ON workspace_app_stats (workspace_id);
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
INSERT INTO public.workspace_app_stats (
|
||||
id,
|
||||
user_id,
|
||||
workspace_id,
|
||||
agent_id,
|
||||
access_method,
|
||||
slug_or_port,
|
||||
session_id,
|
||||
session_started_at,
|
||||
session_ended_at,
|
||||
requests
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
1498,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'562cbfb8-3d9a-4018-9c04-e8159d5aa43e',
|
||||
'2023-08-14 20:15:00+00',
|
||||
'2023-08-14 20:16:00+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
59,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'terminal',
|
||||
'',
|
||||
'281919d0-5d99-48fb-8a93-2c3019010387',
|
||||
'2023-08-14 14:15:40.085827+00',
|
||||
'2023-08-14 14:17:41.295989+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
58,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'5b7c9d43-19e6-4401-997b-c26de2c86c55',
|
||||
'2023-08-14 14:15:34.620496+00',
|
||||
'2023-08-14 23:58:37.158964+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
57,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'fe546a68-0921-4a2b-bced-5dc5c5635576',
|
||||
'2023-08-14 14:15:34.129002+00',
|
||||
'2023-08-14 23:58:37.158901+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
56,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'96e4e857-598c-4881-bc40-e13008b48bb0',
|
||||
'2023-08-14 14:15:00+00',
|
||||
'2023-08-14 14:16:00+00',
|
||||
36
|
||||
),
|
||||
(
|
||||
7,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'terminal',
|
||||
'',
|
||||
'95d22d41-0fde-447b-9743-0b8583edb60a',
|
||||
'2023-08-14 13:00:28.732837+00',
|
||||
'2023-08-14 13:09:23.990797+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
4,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'442688ce-f9e7-46df-ba3d-623ef9a1d30d',
|
||||
'2023-08-14 13:00:12.843977+00',
|
||||
'2023-08-14 13:09:26.276696+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
3,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'f963c4f0-55b7-4813-8b61-ea58536754db',
|
||||
'2023-08-14 13:00:12.323196+00',
|
||||
'2023-08-14 13:09:26.277073+00',
|
||||
1
|
||||
),
|
||||
(
|
||||
2,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'terminal',
|
||||
'',
|
||||
'5a034459-73e4-4642-91b8-80b0f718f29e',
|
||||
'2023-08-14 13:00:00+00',
|
||||
'2023-08-14 13:01:00+00',
|
||||
4
|
||||
),
|
||||
(
|
||||
1,
|
||||
'30095c71-380b-457a-8995-97b8ee6e5307',
|
||||
'3a9a1feb-e89d-457c-9d53-ac751b198ebe',
|
||||
'7a1ce5f8-8d00-431c-ad1b-97a846512804',
|
||||
'path',
|
||||
'code-server',
|
||||
'd7a0d8e1-069e-421d-b876-b5d0ddbcaf6d',
|
||||
'2023-08-14 13:00:00+00',
|
||||
'2023-08-14 13:01:00+00',
|
||||
36
|
||||
);
|
||||
Reference in New Issue
Block a user