Reorder fold page queries to be more in parallel
This commit is contained in:
parent
fdbaa5270b
commit
a90e9b7083
|
@ -48,6 +48,10 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) {
|
||||||
|
|
||||||
const contracts = fold ? await getFoldContracts(fold).catch((_) => []) : []
|
const contracts = fold ? await getFoldContracts(fold).catch((_) => []) : []
|
||||||
|
|
||||||
|
const betsPromise = Promise.all(
|
||||||
|
contracts.map((contract) => listAllBets(contract.id))
|
||||||
|
)
|
||||||
|
|
||||||
const [contractComments, contractRecentBets] = await Promise.all([
|
const [contractComments, contractRecentBets] = await Promise.all([
|
||||||
Promise.all(
|
Promise.all(
|
||||||
contracts.map((contract) => listAllComments(contract.id).catch((_) => []))
|
contracts.map((contract) => listAllComments(contract.id).catch((_) => []))
|
||||||
|
@ -79,17 +83,16 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) {
|
||||||
contractComments[contracts.findIndex((c) => c.id === contract.id)]
|
contractComments[contracts.findIndex((c) => c.id === contract.id)]
|
||||||
)
|
)
|
||||||
|
|
||||||
const curator = await curatorPromise
|
const bets = await betsPromise
|
||||||
|
|
||||||
const bets = await Promise.all(
|
|
||||||
contracts.map((contract) => listAllBets(contract.id))
|
|
||||||
)
|
|
||||||
|
|
||||||
const creatorScores = scoreCreators(contracts, bets)
|
const creatorScores = scoreCreators(contracts, bets)
|
||||||
const topCreators = await toTopUsers(creatorScores)
|
|
||||||
|
|
||||||
const traderScores = scoreTraders(contracts, bets)
|
const traderScores = scoreTraders(contracts, bets)
|
||||||
const topTraders = await toTopUsers(traderScores)
|
const [topCreators, topTraders] = await Promise.all([
|
||||||
|
toTopUsers(creatorScores),
|
||||||
|
toTopUsers(traderScores),
|
||||||
|
])
|
||||||
|
|
||||||
|
const curator = await curatorPromise
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user