Skip to content

feat(coderd): support weekly aggregated insights #9684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 19, 2023
Prev Previous commit
Next Next commit
Remove want
  • Loading branch information
mtojek committed Sep 18, 2023
commit 873ddcd0a404b31b4d9b10ebca14b564d8078123
25 changes: 9 additions & 16 deletions coderd/insights_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,64 +171,57 @@ func Test_parseInsightsInterval_week(t *testing.T) {
endTime string
}
tests := []struct {
name string
args args
wantInterval codersdk.InsightsReportInterval
wantOk bool
name string
args args
wantOk bool
}{
{
name: "Two full weeks",
args: args{
startTime: "2023-08-10T00:00:00+02:00",
endTime: "2023-08-24T00:00:00+02:00",
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: true,
wantOk: true,
},
{
name: "Two weeks",
args: args{
startTime: thirteenDaysAgo.Format(layout),
endTime: twoHoursAgo.Format(layout),
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: true,
wantOk: true,
},
{
name: "One full week",
args: args{
startTime: "2023-09-06T00:00:00+02:00",
endTime: "2023-09-13T00:00:00+02:00",
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: true,
wantOk: true,
},
{
name: "6 days are acceptable",
args: args{
startTime: sixDaysAgo.Format(layout),
endTime: thisHour.Format(layout),
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: true,
wantOk: true,
},
{
name: "Shorter than a full week",
args: args{
startTime: "2023-09-08T00:00:00+02:00",
endTime: "2023-09-13T00:00:00+02:00",
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: false,
wantOk: false,
},
{
name: "9 days (7 + 2) are not acceptable",
args: args{
startTime: nineDaysAgo.Format(layout),
endTime: thisHour.Format(layout),
},
wantInterval: codersdk.InsightsReportIntervalWeek,
wantOk: false,
wantOk: false,
},
}
for _, tt := range tests {
Expand Down