mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Fix Deployment DAUs to work with local timezones (#7647)
* chore: Add timezone param to DAU SQL query * Merge DAUs response * Pass time offsets to metricscache
This commit is contained in:
@@ -55,7 +55,7 @@ func TestDeploymentInsights(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
|
||||
daus, err := client.DeploymentDAUs(context.Background())
|
||||
daus, err := client.DeploymentDAUs(context.Background(), codersdk.TimezoneOffsetHour(time.UTC))
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{})
|
||||
@@ -74,7 +74,7 @@ func TestDeploymentInsights(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_ = sshConn.Close()
|
||||
|
||||
wantDAUs := &codersdk.DeploymentDAUsResponse{
|
||||
wantDAUs := &codersdk.DAUsResponse{
|
||||
Entries: []codersdk.DAUEntry{
|
||||
{
|
||||
Date: time.Now().UTC().Truncate(time.Hour * 24),
|
||||
@@ -83,14 +83,14 @@ func TestDeploymentInsights(t *testing.T) {
|
||||
},
|
||||
}
|
||||
require.Eventuallyf(t, func() bool {
|
||||
daus, err = client.DeploymentDAUs(ctx)
|
||||
daus, err = client.DeploymentDAUs(ctx, codersdk.TimezoneOffsetHour(time.UTC))
|
||||
require.NoError(t, err)
|
||||
return len(daus.Entries) > 0
|
||||
},
|
||||
testutil.WaitShort, testutil.IntervalFast,
|
||||
"deployment daus never loaded",
|
||||
)
|
||||
gotDAUs, err := client.DeploymentDAUs(ctx)
|
||||
gotDAUs, err := client.DeploymentDAUs(ctx, codersdk.TimezoneOffsetHour(time.UTC))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, gotDAUs, wantDAUs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user