Skip to content

Commit 3d43926

Browse files
committed
add 15 min of app usage -> active user on last day
1 parent 6c1dbe0 commit 3d43926

4 files changed

+59
-20
lines changed

coderd/insights_test.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,24 +1061,27 @@ func TestTemplateInsights_Golden(t *testing.T) {
10611061
endedAt: weekAgo.Add(time.Hour),
10621062
requests: 1,
10631063
},
1064-
// { // used an app on the last day, counts as active user.
1065-
// app: users[0].workspaces[0].apps[2],
1066-
// startedAt: weekAgo.AddDate(0, 0, 6),
1067-
// endedAt: weekAgo.AddDate(0, 0, 6).Add(12 * time.Minute),
1064+
{ // used an app on the last day, counts as active user, 12m -> 15m rounded.
1065+
app: users[0].workspaces[0].apps[2],
1066+
startedAt: weekAgo.AddDate(0, 0, 6),
1067+
endedAt: weekAgo.AddDate(0, 0, 6).Add(12 * time.Minute),
1068+
requests: 1,
1069+
},
1070+
},
1071+
},
1072+
users[0].workspaces[1]: {
1073+
appUsage: []appUsage{
1074+
// TODO(mafredri): This doesn't behave correctly right now
1075+
// and will add more usage to the app. This could be
1076+
// considered both correct and incorrect behavior.
1077+
// { // One hour of usage, but same user and same template app, only count once.
1078+
// app: users[0].workspaces[1].apps[0],
1079+
// startedAt: weekAgo,
1080+
// endedAt: weekAgo.Add(time.Hour),
10681081
// requests: 1,
10691082
// },
10701083
},
10711084
},
1072-
// users[0].workspaces[1]: {
1073-
// appUsage: []appUsage{
1074-
// { // One hour of usage, but same user and same template app, only count once.
1075-
// app: users[0].workspaces[1].apps[0],
1076-
// startedAt: weekAgo,
1077-
// endedAt: weekAgo.Add(time.Hour),
1078-
// requests: 1,
1079-
// },
1080-
// },
1081-
// },
10821085
}
10831086
}
10841087
type testRequest struct {

coderd/testdata/insights/multiple_users_and_workspaces_week_all_templates.json.golden

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
"slug": "app1",
5757
"icon": "/icon1.png",
5858
"seconds": 3600
59+
},
60+
{
61+
"template_ids": [
62+
"00000000-0000-0000-0000-000000000001"
63+
],
64+
"type": "app",
65+
"display_name": "app3",
66+
"slug": "app3",
67+
"icon": "/icon2.png",
68+
"seconds": 900
5969
}
6070
],
6171
"parameters_usage": []
@@ -112,9 +122,11 @@
112122
{
113123
"start_time": "2023-08-21T00:00:00Z",
114124
"end_time": "2023-08-22T00:00:00Z",
115-
"template_ids": [],
125+
"template_ids": [
126+
"00000000-0000-0000-0000-000000000001"
127+
],
116128
"interval": "day",
117-
"active_users": 0
129+
"active_users": 1
118130
}
119131
]
120132
}

coderd/testdata/insights/multiple_users_and_workspaces_week_deployment_wide.json.golden

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
"slug": "app1",
5757
"icon": "/icon1.png",
5858
"seconds": 3600
59+
},
60+
{
61+
"template_ids": [
62+
"00000000-0000-0000-0000-000000000001"
63+
],
64+
"type": "app",
65+
"display_name": "app3",
66+
"slug": "app3",
67+
"icon": "/icon2.png",
68+
"seconds": 900
5969
}
6070
],
6171
"parameters_usage": []
@@ -112,9 +122,11 @@
112122
{
113123
"start_time": "2023-08-21T00:00:00Z",
114124
"end_time": "2023-08-22T00:00:00Z",
115-
"template_ids": [],
125+
"template_ids": [
126+
"00000000-0000-0000-0000-000000000001"
127+
],
116128
"interval": "day",
117-
"active_users": 0
129+
"active_users": 1
118130
}
119131
]
120132
}

coderd/testdata/insights/multiple_users_and_workspaces_week_first_template.json.golden

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
"slug": "app1",
5757
"icon": "/icon1.png",
5858
"seconds": 3600
59+
},
60+
{
61+
"template_ids": [
62+
"00000000-0000-0000-0000-000000000001"
63+
],
64+
"type": "app",
65+
"display_name": "app3",
66+
"slug": "app3",
67+
"icon": "/icon2.png",
68+
"seconds": 900
5969
}
6070
],
6171
"parameters_usage": []
@@ -112,9 +122,11 @@
112122
{
113123
"start_time": "2023-08-21T00:00:00Z",
114124
"end_time": "2023-08-22T00:00:00Z",
115-
"template_ids": [],
125+
"template_ids": [
126+
"00000000-0000-0000-0000-000000000001"
127+
],
116128
"interval": "day",
117-
"active_users": 0
129+
"active_users": 1
118130
}
119131
]
120132
}

0 commit comments

Comments
 (0)