mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00: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:
@ -93,3 +93,24 @@ func ConvertUserRows(rows []GetUsersRow) []User {
|
||||
|
||||
return users
|
||||
}
|
||||
|
||||
func ConvertWorkspaceRows(rows []GetWorkspacesRow) []Workspace {
|
||||
workspaces := make([]Workspace, len(rows))
|
||||
for i, r := range rows {
|
||||
workspaces[i] = Workspace{
|
||||
ID: r.ID,
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
OwnerID: r.OwnerID,
|
||||
OrganizationID: r.OrganizationID,
|
||||
TemplateID: r.TemplateID,
|
||||
Deleted: r.Deleted,
|
||||
Name: r.Name,
|
||||
AutostartSchedule: r.AutostartSchedule,
|
||||
Ttl: r.Ttl,
|
||||
LastUsedAt: r.LastUsedAt,
|
||||
}
|
||||
}
|
||||
|
||||
return workspaces
|
||||
}
|
||||
|
Reference in New Issue
Block a user