mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
fix: Only update workspace LastUsed when the connection payload has changed (#4115)
This was causing every workspace to update last used to time.Now() when coderd was restarted!
This commit is contained in:
@ -159,6 +159,33 @@ func (q *fakeQuerier) InsertAgentStat(_ context.Context, p database.InsertAgentS
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetLatestAgentStat(_ context.Context, agentID uuid.UUID) (database.AgentStat, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
found := false
|
||||
latest := database.AgentStat{}
|
||||
for _, agentStat := range q.agentStats {
|
||||
if agentStat.AgentID != agentID {
|
||||
continue
|
||||
}
|
||||
if !found {
|
||||
latest = agentStat
|
||||
found = true
|
||||
continue
|
||||
}
|
||||
if agentStat.CreatedAt.After(latest.CreatedAt) {
|
||||
latest = agentStat
|
||||
found = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return database.AgentStat{}, sql.ErrNoRows
|
||||
}
|
||||
return latest, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, templateID uuid.UUID) ([]database.GetTemplateDAUsRow, error) {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
Reference in New Issue
Block a user