mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: refactor workspaces query to use window function (#5079)
* Use window function in query * Convert workspace rows and unpack count * Update types * Fix Scan bug * Remove getCountError
This commit is contained in:
@@ -380,10 +380,11 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
|
||||
return nil
|
||||
})
|
||||
eg.Go(func() error {
|
||||
workspaces, err := r.options.Database.GetWorkspaces(ctx, database.GetWorkspacesParams{})
|
||||
workspaceRows, err := r.options.Database.GetWorkspaces(ctx, database.GetWorkspacesParams{})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("get workspaces: %w", err)
|
||||
}
|
||||
workspaces := database.ConvertWorkspaceRows(workspaceRows)
|
||||
snapshot.Workspaces = make([]Workspace, 0, len(workspaces))
|
||||
for _, dbWorkspace := range workspaces {
|
||||
snapshot.Workspaces = append(snapshot.Workspaces, ConvertWorkspace(dbWorkspace))
|
||||
|
||||
Reference in New Issue
Block a user