mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: use dbtime in dbmem query to fix flake (#16773)
Closes https://github.com/coder/internal/issues/447. The test was failing 30% of the time on Windows without the rounding applied by `dbtime`. `dbtime` was used on the timestamps inserted into the DB, but not within the query. Once using `dbtime` within the query there were no failures in 200 runs.
This commit is contained in:
@ -7014,7 +7014,7 @@ func (q *FakeQuerier) GetWorkspaceAgentUsageStatsAndLabels(_ context.Context, cr
|
||||
}
|
||||
// WHERE usage = true AND created_at > now() - '1 minute'::interval
|
||||
// GROUP BY user_id, agent_id, workspace_id
|
||||
if agentStat.Usage && agentStat.CreatedAt.After(time.Now().Add(-time.Minute)) {
|
||||
if agentStat.Usage && agentStat.CreatedAt.After(dbtime.Now().Add(-time.Minute)) {
|
||||
val, ok := latestAgentStats[key]
|
||||
if !ok {
|
||||
latestAgentStats[key] = agentStat
|
||||
|
Reference in New Issue
Block a user