Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
test(dashboard): anchor window fixtures on the UTC date (MUL-8987) (#10323)
Jiayuan Zhange8255d98aba2
diff --git a/server/internal/handler/dashboard_test.go b/server/internal/handler/dashboard_test.goindex 084715bddf..a1926bae95 100644--- a/server/internal/handler/dashboard_test.go+++ b/server/internal/handler/dashboard_test.go@@ -449,7 +449,7 @@ func TestDashboardUsageDailyBucketsByViewerTimezone(t *testing.T) {input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, event_count)VALUES (- ((CURRENT_DATE - 2)::timestamp + interval '4 hours') AT TIME ZONE 'UTC',+ (((now() AT TIME ZONE 'UTC')::date - 2)::timestamp + interval '4 hours') AT TIME ZONE 'UTC',$1, $2, $3, NULL, 'tz-bucket-test', 'tz-bucket-model',999, 0, 0, 0, 1)@@ -530,8 +530,8 @@ func TestDashboardRunTimeDailyBucketsByViewerTimezone(t *testing.T) {INSERT INTO agent_task_queue (agent_id, issue_id, runtime_id, status, started_at, completed_at, created_at)VALUES ($1, $2, $3, 'completed',- ((CURRENT_DATE - 2)::timestamp + interval '3 hours 50 minutes') AT TIME ZONE 'UTC',- ((CURRENT_DATE - 2)::timestamp + interval '4 hours') AT TIME ZONE 'UTC',+ (((now() AT TIME ZONE 'UTC')::date - 2)::timestamp + interval '3 hours 50 minutes') AT TIME ZONE 'UTC',+ (((now() AT TIME ZONE 'UTC')::date - 2)::timestamp + interval '4 hours') AT TIME ZONE 'UTC',now())RETURNING id, completed_at@@ -1351,14 +1351,15 @@ func TestDashboardUsageDailyCrossMidnightFullPipeline(t *testing.T) {// Raw task_usage at 00:30 UTC two days ago — genuinely near UTC// midnight. 00:30 UTC is still the PRIOR evening (~16:30/17:30) in// America/Los_Angeles (UTC-7/-8), so the UTC viewer and the LA viewer- // must see this row under different calendar days. Using CURRENT_DATE- // keeps the row inside the days=10 window without a fixed-date drift.+ // must see this row under different calendar days. Anchoring on today's+ // UTC date keeps the row inside the days=10 window without a fixed-date+ // drift.var usageAt time.Timedbfx.QueryRow(t, `INSERT INTO task_usage (task_id, provider, model, input_tokens, output_tokens, created_at)VALUES ($1, 'claude', 'cross-midnight-model', 8888, 0,- ((CURRENT_DATE - 2)::timestamp + interval '30 minutes') AT TIME ZONE 'UTC'+ (((now() AT TIME ZONE 'UTC')::date - 2)::timestamp + interval '30 minutes') AT TIME ZONE 'UTC')RETURNING created_at`, taskID).Scan(&usageAt)@@ -1638,13 +1639,15 @@ func TestDashboardFailuresByAgentUsesExactWindow(t *testing.T) {// One failure at noon YESTERDAY (UTC). days=1 means "today", so neither// endpoint may count it. Noon avoids the midnight edge in either- // direction.+ // direction. Fixtures in this file derive dates from now() in UTC, not+ // CURRENT_DATE, which follows the session timezone and is already UTC+ // tomorrow on a UTC+8 server between 00:00 and 08:00 local.dbfx.Task(t, agentID, testutil.Cols{"issue_id": issueID,"runtime_id": runtimeID,"status": "failed",- "started_at": testutil.Raw("((CURRENT_DATE - 1)::timestamp + interval '11 hours') AT TIME ZONE 'UTC'"),- "completed_at": testutil.Raw("((CURRENT_DATE - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC'"),+ "started_at": testutil.Raw("(((now() AT TIME ZONE 'UTC')::date - 1)::timestamp + interval '11 hours') AT TIME ZONE 'UTC'"),+ "completed_at": testutil.Raw("(((now() AT TIME ZONE 'UTC')::date - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC'"),"failure_reason": "timeout","created_at": testutil.Raw("now()"),})@@ -1739,7 +1742,7 @@ func TestDashboardPerAgentRollupsUseExactWindow(t *testing.T) {input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, event_count)VALUES (- ((CURRENT_DATE - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC',+ (((now() AT TIME ZONE 'UTC')::date - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC',$1, $2, $3, NULL, $4, $5,7777, 0, 0, 0, 1)@@ -1754,8 +1757,8 @@ func TestDashboardPerAgentRollupsUseExactWindow(t *testing.T) {"issue_id": issueID,"runtime_id": runtimeID,"status": "completed",- "started_at": testutil.Raw("((CURRENT_DATE - 1)::timestamp + interval '11 hours 45 minutes') AT TIME ZONE 'UTC'"),- "completed_at": testutil.Raw("((CURRENT_DATE - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC'"),+ "started_at": testutil.Raw("(((now() AT TIME ZONE 'UTC')::date - 1)::timestamp + interval '11 hours 45 minutes') AT TIME ZONE 'UTC'"),+ "completed_at": testutil.Raw("(((now() AT TIME ZONE 'UTC')::date - 1)::timestamp + interval '12 hours') AT TIME ZONE 'UTC'"),"created_at": testutil.Raw("now()"),})