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
@@ -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
}