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:
@@ -27,8 +27,7 @@ const WorkspacesPage: FC = () => {
|
||||
},
|
||||
})
|
||||
|
||||
const { workspaceRefs, count, getWorkspacesError, getCountError } =
|
||||
workspacesState.context
|
||||
const { workspaceRefs, count, getWorkspacesError } = workspacesState.context
|
||||
const paginationRef = workspacesState.context
|
||||
.paginationRef as PaginationMachineRef
|
||||
|
||||
@@ -44,7 +43,6 @@ const WorkspacesPage: FC = () => {
|
||||
workspaceRefs={workspaceRefs}
|
||||
count={count}
|
||||
getWorkspacesError={getWorkspacesError}
|
||||
getCountError={getCountError}
|
||||
onFilter={(query) => {
|
||||
send({
|
||||
type: "UPDATE_FILTER",
|
||||
|
||||
@@ -32,7 +32,6 @@ export interface WorkspacesPageViewProps {
|
||||
workspaceRefs?: WorkspaceItemMachineRef[]
|
||||
count?: number
|
||||
getWorkspacesError: Error | unknown
|
||||
getCountError: Error | unknown
|
||||
filter?: string
|
||||
onFilter: (query: string) => void
|
||||
paginationRef: PaginationMachineRef
|
||||
@@ -46,7 +45,6 @@ export const WorkspacesPageView: FC<
|
||||
workspaceRefs,
|
||||
count,
|
||||
getWorkspacesError,
|
||||
getCountError,
|
||||
filter,
|
||||
onFilter,
|
||||
paginationRef,
|
||||
@@ -92,10 +90,6 @@ export const WorkspacesPageView: FC<
|
||||
/>
|
||||
</Maybe>
|
||||
|
||||
<Maybe condition={getCountError !== undefined}>
|
||||
<AlertBanner error={getCountError} severity="warning" />
|
||||
</Maybe>
|
||||
|
||||
<SearchBarWithFilter
|
||||
filter={filter}
|
||||
onFilter={onFilter}
|
||||
|
||||
@@ -216,7 +216,6 @@ interface WorkspacesContext {
|
||||
filter: string
|
||||
count?: number
|
||||
getWorkspacesError?: Error | unknown
|
||||
getCountError?: Error | unknown
|
||||
paginationContext: PaginationContext
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user