diff --git a/coderd/httpmw/workspaceagentparam_test.go b/coderd/httpmw/workspaceagentparam_test.go index 127dda843f..c1a5aef4e8 100644 --- a/coderd/httpmw/workspaceagentparam_test.go +++ b/coderd/httpmw/workspaceagentparam_test.go @@ -6,12 +6,12 @@ import ( "net/http/httptest" "testing" - "cdr.dev/slog" "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/stretchr/testify/require" "golang.org/x/xerrors" + "cdr.dev/slog" "github.com/coder/coder/v2/coderd/coderdtest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbauthz" diff --git a/coderd/metricscache/metricscache.go b/coderd/metricscache/metricscache.go index e3ac274b1c..256564b671 100644 --- a/coderd/metricscache/metricscache.go +++ b/coderd/metricscache/metricscache.go @@ -26,8 +26,14 @@ import ( // Any non-listed timezone offsets will need to use the closest supported one. var deploymentTimezoneOffsets = []int{ 0, // UTC - is listed first intentionally. - -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + // Shortened list of 4 timezones that should encompass *most* users. Caching + // all 25 timezones can be too computationally expensive for large + // deployments. This is a stop-gap until more robust fixes can be made for + // the deployment DAUs query. + -6, 3, 6, 10, + + // -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, + // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, } // templateTimezoneOffsets are the timezones each template will use for it's DAU diff --git a/coderd/metricscache/metricscache_test.go b/coderd/metricscache/metricscache_test.go index 5e226ae68f..30325e2e88 100644 --- a/coderd/metricscache/metricscache_test.go +++ b/coderd/metricscache/metricscache_test.go @@ -152,11 +152,11 @@ func TestCache_TemplateUsers(t *testing.T) { }, { name: "tzOffset", - tzOffset: 1, + tzOffset: 3, args: args{ rows: []database.InsertWorkspaceAgentStatParams{ - statRow(zebra, dateH(2022, 1, 2, 1)), - statRow(tiger, dateH(2022, 1, 2, 1)), + statRow(zebra, dateH(2022, 1, 2, 3)), + statRow(tiger, dateH(2022, 1, 2, 3)), // With offset these should be in the previous day statRow(zebra, dateH(2022, 1, 2, 0)), statRow(tiger, dateH(2022, 1, 2, 0)), diff --git a/codersdk/deployment.go b/codersdk/deployment.go index ec2fcc94df..5bc3d30a9a 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -1630,7 +1630,7 @@ when required by your organization's security policy.`, Flag: "metrics-cache-refresh-interval", Env: "CODER_METRICS_CACHE_REFRESH_INTERVAL", Hidden: true, - Default: time.Hour.String(), + Default: (4 * time.Hour).String(), Value: &c.MetricsCacheRefreshInterval, Annotations: clibase.Annotations{}.Mark(annotationFormatDuration, "true"), },