Skip to content

Commit

Permalink
retry chain stats
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Dec 6, 2024
1 parent 0aae9aa commit 32f1b57
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions apps/dapp/pages/[[...tab]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
chainIsIndexed,
getDaoInfoForChainId,
getSupportedChains,
retry,
} from '@dao-dao/utils'

export default Home
Expand Down Expand Up @@ -70,56 +71,63 @@ export const getStaticProps: GetStaticProps<StatefulHomeProps> = async ({

// Get all or chain-specific stats and TVL.
!chainId || chainIsIndexed(chainId)
? queryClient
.fetchQuery(
? retry(5, () =>
queryClient.fetchQuery(
indexerQueries.snapper<number>({
query: chainId ? 'daodao-chain-tvl' : 'daodao-all-tvl',
parameters: chainId ? { chainId } : undefined,
})
)
.catch(() => 0)
).catch(() => 0)
: null,
!chainId || chainIsIndexed(chainId)
? queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: chainId ? { chainId } : undefined,
})
? retry(5, () =>
queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: chainId ? { chainId } : undefined,
})
)
)
: null,
!chainId || chainIsIndexed(chainId)
? queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: {
...(chainId ? { chainId } : undefined),
daysAgo: 30,
},
})
? retry(5, () =>
queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: {
...(chainId ? { chainId } : undefined),
daysAgo: 30,
},
})
)
)
: null,
!chainId || chainIsIndexed(chainId)
? queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: {
...(chainId ? { chainId } : undefined),
daysAgo: 7,
},
})
? retry(5, () =>
queryClient.fetchQuery(
indexerQueries.snapper<DaoDaoIndexerChainStats>({
query: chainId ? 'daodao-chain-stats' : 'daodao-all-stats',
parameters: {
...(chainId ? { chainId } : undefined),
daysAgo: 7,
},
})
)
)
: null,

// Pre-fetch featured DAOs.
queryClient
.fetchQuery(daoQueries.listFeatured())
.then((featured) =>
retry(5, () => queryClient.fetchQuery(daoQueries.listFeatured())).then(
(featured) =>
Promise.all(
featured?.map((dao) =>
queryClient.fetchQuery(statefulDaoQueries.info(queryClient, dao))
retry(5, () =>
queryClient.fetchQuery(statefulDaoQueries.info(queryClient, dao))
)
) || []
)
),
),
])

return {
Expand Down

0 comments on commit 32f1b57

Please sign in to comment.