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:
Presley Pizzo
2022-11-16 10:16:37 -05:00
committed by GitHub
parent 560d3c9fd0
commit e6ead7d915
12 changed files with 93 additions and 43 deletions

View File

@ -124,7 +124,7 @@ type sqlcQuerier interface {
GetWorkspaceResourcesByJobID(ctx context.Context, jobID uuid.UUID) ([]WorkspaceResource, error)
GetWorkspaceResourcesByJobIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceResource, error)
GetWorkspaceResourcesCreatedAfter(ctx context.Context, createdAt time.Time) ([]WorkspaceResource, error)
GetWorkspaces(ctx context.Context, arg GetWorkspacesParams) ([]Workspace, error)
GetWorkspaces(ctx context.Context, arg GetWorkspacesParams) ([]GetWorkspacesRow, error)
InsertAPIKey(ctx context.Context, arg InsertAPIKeyParams) (APIKey, error)
InsertAgentStat(ctx context.Context, arg InsertAgentStatParams) (AgentStat, error)
// We use the organization_id as the id