Skip to content

Commit ec4f48f

Browse files
committed
add identical usage in two templates for one user
1 parent 3c4cbd0 commit ec4f48f

4 files changed

+68
-32
lines changed

coderd/insights_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,18 @@ func TestTemplateInsights_Golden(t *testing.T) {
10701070
},
10711071
},
10721072
users[0].workspaces[1]: {
1073+
agentStats: []agentStat{
1074+
{
1075+
// One hour of usage in second template at the same time
1076+
// as in first template. When selecting both templates
1077+
// this user and their app usage will only be counted
1078+
// once but the template ID will show up in the data.
1079+
startedAt: weekAgo,
1080+
endedAt: weekAgo.Add(time.Hour),
1081+
sessionCountVSCode: 1,
1082+
sessionCountSSH: 1,
1083+
},
1084+
},
10731085
appUsage: []appUsage{
10741086
// TODO(mafredri): This doesn't behave correctly right now
10751087
// and will add more usage to the app. This could be

coderd/testdata/insights/multiple_users_and_workspaces_week_all_templates.json.golden

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"start_time": "2023-08-15T00:00:00Z",
44
"end_time": "2023-08-22T00:00:00Z",
55
"template_ids": [
6-
"00000000-0000-0000-0000-000000000001"
6+
"00000000-0000-0000-0000-000000000001",
7+
"00000000-0000-0000-0000-000000000002"
78
],
89
"active_users": 1,
910
"apps_usage": [
1011
{
1112
"template_ids": [
12-
"00000000-0000-0000-0000-000000000001"
13+
"00000000-0000-0000-0000-000000000001",
14+
"00000000-0000-0000-0000-000000000002"
1315
],
1416
"type": "builtin",
1517
"display_name": "Visual Studio Code",
@@ -19,7 +21,8 @@
1921
},
2022
{
2123
"template_ids": [
22-
"00000000-0000-0000-0000-000000000001"
24+
"00000000-0000-0000-0000-000000000001",
25+
"00000000-0000-0000-0000-000000000002"
2326
],
2427
"type": "builtin",
2528
"display_name": "JetBrains",
@@ -29,7 +32,8 @@
2932
},
3033
{
3134
"template_ids": [
32-
"00000000-0000-0000-0000-000000000001"
35+
"00000000-0000-0000-0000-000000000001",
36+
"00000000-0000-0000-0000-000000000002"
3337
],
3438
"type": "builtin",
3539
"display_name": "Web Terminal",
@@ -39,7 +43,8 @@
3943
},
4044
{
4145
"template_ids": [
42-
"00000000-0000-0000-0000-000000000001"
46+
"00000000-0000-0000-0000-000000000001",
47+
"00000000-0000-0000-0000-000000000002"
4348
],
4449
"type": "builtin",
4550
"display_name": "SSH",
@@ -49,7 +54,7 @@
4954
},
5055
{
5156
"template_ids": [
52-
"00000000-0000-0000-0000-000000000001"
57+
"00000000-0000-0000-0000-000000000002"
5358
],
5459
"type": "app",
5560
"display_name": "app1",
@@ -59,7 +64,7 @@
5964
},
6065
{
6166
"template_ids": [
62-
"00000000-0000-0000-0000-000000000001"
67+
"00000000-0000-0000-0000-000000000002"
6368
],
6469
"type": "app",
6570
"display_name": "app3",
@@ -75,7 +80,8 @@
7580
"start_time": "2023-08-15T00:00:00Z",
7681
"end_time": "2023-08-16T00:00:00Z",
7782
"template_ids": [
78-
"00000000-0000-0000-0000-000000000001"
83+
"00000000-0000-0000-0000-000000000001",
84+
"00000000-0000-0000-0000-000000000002"
7985
],
8086
"interval": "day",
8187
"active_users": 1
@@ -84,7 +90,7 @@
8490
"start_time": "2023-08-16T00:00:00Z",
8591
"end_time": "2023-08-17T00:00:00Z",
8692
"template_ids": [
87-
"00000000-0000-0000-0000-000000000001"
93+
"00000000-0000-0000-0000-000000000002"
8894
],
8995
"interval": "day",
9096
"active_users": 1
@@ -93,7 +99,7 @@
9399
"start_time": "2023-08-17T00:00:00Z",
94100
"end_time": "2023-08-18T00:00:00Z",
95101
"template_ids": [
96-
"00000000-0000-0000-0000-000000000001"
102+
"00000000-0000-0000-0000-000000000002"
97103
],
98104
"interval": "day",
99105
"active_users": 1
@@ -123,7 +129,7 @@
123129
"start_time": "2023-08-21T00:00:00Z",
124130
"end_time": "2023-08-22T00:00:00Z",
125131
"template_ids": [
126-
"00000000-0000-0000-0000-000000000001"
132+
"00000000-0000-0000-0000-000000000002"
127133
],
128134
"interval": "day",
129135
"active_users": 1

coderd/testdata/insights/multiple_users_and_workspaces_week_deployment_wide.json.golden

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"start_time": "2023-08-15T00:00:00Z",
44
"end_time": "2023-08-22T00:00:00Z",
55
"template_ids": [
6-
"00000000-0000-0000-0000-000000000001"
6+
"00000000-0000-0000-0000-000000000001",
7+
"00000000-0000-0000-0000-000000000002"
78
],
89
"active_users": 1,
910
"apps_usage": [
1011
{
1112
"template_ids": [
12-
"00000000-0000-0000-0000-000000000001"
13+
"00000000-0000-0000-0000-000000000001",
14+
"00000000-0000-0000-0000-000000000002"
1315
],
1416
"type": "builtin",
1517
"display_name": "Visual Studio Code",
@@ -19,7 +21,8 @@
1921
},
2022
{
2123
"template_ids": [
22-
"00000000-0000-0000-0000-000000000001"
24+
"00000000-0000-0000-0000-000000000001",
25+
"00000000-0000-0000-0000-000000000002"
2326
],
2427
"type": "builtin",
2528
"display_name": "JetBrains",
@@ -29,7 +32,8 @@
2932
},
3033
{
3134
"template_ids": [
32-
"00000000-0000-0000-0000-000000000001"
35+
"00000000-0000-0000-0000-000000000001",
36+
"00000000-0000-0000-0000-000000000002"
3337
],
3438
"type": "builtin",
3539
"display_name": "Web Terminal",
@@ -39,7 +43,8 @@
3943
},
4044
{
4145
"template_ids": [
42-
"00000000-0000-0000-0000-000000000001"
46+
"00000000-0000-0000-0000-000000000001",
47+
"00000000-0000-0000-0000-000000000002"
4348
],
4449
"type": "builtin",
4550
"display_name": "SSH",
@@ -49,7 +54,7 @@
4954
},
5055
{
5156
"template_ids": [
52-
"00000000-0000-0000-0000-000000000001"
57+
"00000000-0000-0000-0000-000000000002"
5358
],
5459
"type": "app",
5560
"display_name": "app1",
@@ -59,7 +64,7 @@
5964
},
6065
{
6166
"template_ids": [
62-
"00000000-0000-0000-0000-000000000001"
67+
"00000000-0000-0000-0000-000000000002"
6368
],
6469
"type": "app",
6570
"display_name": "app3",
@@ -75,7 +80,8 @@
7580
"start_time": "2023-08-15T00:00:00Z",
7681
"end_time": "2023-08-16T00:00:00Z",
7782
"template_ids": [
78-
"00000000-0000-0000-0000-000000000001"
83+
"00000000-0000-0000-0000-000000000001",
84+
"00000000-0000-0000-0000-000000000002"
7985
],
8086
"interval": "day",
8187
"active_users": 1
@@ -84,7 +90,7 @@
8490
"start_time": "2023-08-16T00:00:00Z",
8591
"end_time": "2023-08-17T00:00:00Z",
8692
"template_ids": [
87-
"00000000-0000-0000-0000-000000000001"
93+
"00000000-0000-0000-0000-000000000002"
8894
],
8995
"interval": "day",
9096
"active_users": 1
@@ -93,7 +99,7 @@
9399
"start_time": "2023-08-17T00:00:00Z",
94100
"end_time": "2023-08-18T00:00:00Z",
95101
"template_ids": [
96-
"00000000-0000-0000-0000-000000000001"
102+
"00000000-0000-0000-0000-000000000002"
97103
],
98104
"interval": "day",
99105
"active_users": 1
@@ -123,7 +129,7 @@
123129
"start_time": "2023-08-21T00:00:00Z",
124130
"end_time": "2023-08-22T00:00:00Z",
125131
"template_ids": [
126-
"00000000-0000-0000-0000-000000000001"
132+
"00000000-0000-0000-0000-000000000002"
127133
],
128134
"interval": "day",
129135
"active_users": 1

coderd/testdata/insights/multiple_users_and_workspaces_week_second_template.json.golden

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,50 @@
22
"report": {
33
"start_time": "2023-08-15T00:00:00Z",
44
"end_time": "2023-08-22T00:00:00Z",
5-
"template_ids": [],
6-
"active_users": 0,
5+
"template_ids": [
6+
"00000000-0000-0000-0000-000000000001"
7+
],
8+
"active_users": 1,
79
"apps_usage": [
810
{
9-
"template_ids": [],
11+
"template_ids": [
12+
"00000000-0000-0000-0000-000000000001"
13+
],
1014
"type": "builtin",
1115
"display_name": "Visual Studio Code",
1216
"slug": "vscode",
1317
"icon": "/icon/code.svg",
14-
"seconds": 0
18+
"seconds": 3600
1519
},
1620
{
17-
"template_ids": [],
21+
"template_ids": [
22+
"00000000-0000-0000-0000-000000000001"
23+
],
1824
"type": "builtin",
1925
"display_name": "JetBrains",
2026
"slug": "jetbrains",
2127
"icon": "/icon/intellij.svg",
2228
"seconds": 0
2329
},
2430
{
25-
"template_ids": [],
31+
"template_ids": [
32+
"00000000-0000-0000-0000-000000000001"
33+
],
2634
"type": "builtin",
2735
"display_name": "Web Terminal",
2836
"slug": "reconnecting-pty",
2937
"icon": "/icon/terminal.svg",
3038
"seconds": 0
3139
},
3240
{
33-
"template_ids": [],
41+
"template_ids": [
42+
"00000000-0000-0000-0000-000000000001"
43+
],
3444
"type": "builtin",
3545
"display_name": "SSH",
3646
"slug": "ssh",
3747
"icon": "/icon/terminal.svg",
38-
"seconds": 0
48+
"seconds": 3600
3949
}
4050
],
4151
"parameters_usage": []
@@ -44,9 +54,11 @@
4454
{
4555
"start_time": "2023-08-15T00:00:00Z",
4656
"end_time": "2023-08-16T00:00:00Z",
47-
"template_ids": [],
57+
"template_ids": [
58+
"00000000-0000-0000-0000-000000000001"
59+
],
4860
"interval": "day",
49-
"active_users": 0
61+
"active_users": 1
5062
},
5163
{
5264
"start_time": "2023-08-16T00:00:00Z",

0 commit comments

Comments
 (0)