Skip to content

Commit

Permalink
single-line queries with shorter const name
Browse files Browse the repository at this point in the history
  • Loading branch information
charliepark committed Sep 20, 2024
1 parent 8c2b962 commit 8146491
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 36 deletions.
4 changes: 1 addition & 3 deletions app/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ if (typeof window !== 'undefined') {
return data
},
schemas: async (search?: string) => {
const result = await api.methods.timeseriesSchemaList({
query: { limit: ALL_ISH },
})
const result = await api.methods.timeseriesSchemaList({ query: { limit: ALL_ISH } })
const data = handleResult(result)

let filtered = data.items
Expand Down
8 changes: 2 additions & 6 deletions app/forms/firewall-rules-common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,10 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) =
// prefetchedApiQueries below are prefetched in firewall-rules-create and -edit
const {
data: { items: instances },
} = usePrefetchedApiQuery('instanceList', {
query: { project, limit: ALL_ISH },
})
} = usePrefetchedApiQuery('instanceList', { query: { project, limit: ALL_ISH } })
const {
data: { items: vpcs },
} = usePrefetchedApiQuery('vpcList', {
query: { project, limit: ALL_ISH },
})
} = usePrefetchedApiQuery('vpcList', { query: { project, limit: ALL_ISH } })
const {
data: { items: vpcSubnets },
} = usePrefetchedApiQuery('vpcSubnetList', { query: { project, vpc } })
Expand Down
8 changes: 2 additions & 6 deletions app/forms/firewall-rules-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ CreateFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
const { project, vpc } = getVpcSelector(params)
await Promise.all([
apiQueryClient.prefetchQuery('vpcFirewallRulesView', { query: { project, vpc } }),
apiQueryClient.prefetchQuery('instanceList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('vpcList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: ALL_ISH } }),
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: ALL_ISH } }),
apiQueryClient.prefetchQuery('vpcSubnetList', { query: { project, vpc } }),
])

Expand Down
8 changes: 2 additions & 6 deletions app/forms/firewall-rules-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ EditFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {

const [firewallRules] = await Promise.all([
apiQueryClient.fetchQuery('vpcFirewallRulesView', { query: { project, vpc } }),
apiQueryClient.prefetchQuery('instanceList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('vpcList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: ALL_ISH } }),
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: ALL_ISH } }),
apiQueryClient.prefetchQuery('vpcSubnetList', { query: { project, vpc } }),
])

Expand Down
4 changes: 1 addition & 3 deletions app/forms/floating-ip-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const defaultValues: Omit<FloatingIpCreate, 'ip'> = {
export function CreateFloatingIpSideModalForm() {
// Fetch 1000 to we can be sure to get them all. Don't bother prefetching
// because the list is hidden under the Advanced accordion.
const { data: allPools } = useApiQuery('projectIpPoolList', {
query: { limit: ALL_ISH },
})
const { data: allPools } = useApiQuery('projectIpPoolList', { query: { limit: ALL_ISH } })

const queryClient = useApiQueryClient()
const projectSelector = useProjectSelector()
Expand Down
8 changes: 2 additions & 6 deletions app/forms/instance-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,8 @@ CreateInstanceForm.loader = async ({ params }: LoaderFunctionArgs) => {
query: { project, limit: DISK_FETCH_LIMIT },
}),
apiQueryClient.prefetchQuery('currentUserSshKeyList', {}),
apiQueryClient.prefetchQuery('projectIpPoolList', {
query: { limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('floatingIpList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('projectIpPoolList', { query: { limit: ALL_ISH } }),
apiQueryClient.prefetchQuery('floatingIpList', { query: { project, limit: ALL_ISH } }),
])
return null
}
Expand Down
8 changes: 2 additions & 6 deletions app/pages/project/instances/instance/tabs/NetworkingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ NetworkingTab.loader = async ({ params }: LoaderFunctionArgs) => {
// we want this to cover all NICs; TODO: determine actual limit?
query: { project, instance, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('floatingIpList', {
query: { project, limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('floatingIpList', { query: { project, limit: ALL_ISH } }),
// dupe of page-level fetch but that's fine, RQ dedupes
apiQueryClient.prefetchQuery('instanceExternalIpList', {
path: { instance },
Expand All @@ -104,9 +102,7 @@ NetworkingTab.loader = async ({ params }: LoaderFunctionArgs) => {
query: { project },
}),
// This is used in AttachEphemeralIpModal
apiQueryClient.prefetchQuery('projectIpPoolList', {
query: { limit: ALL_ISH },
}),
apiQueryClient.prefetchQuery('projectIpPoolList', { query: { limit: ALL_ISH } }),
])
return null
}
Expand Down

0 comments on commit 8146491

Please sign in to comment.