Skip to content

Commit

Permalink
Parallelize API requests on profile
Browse files Browse the repository at this point in the history
  • Loading branch information
reneklacan committed Feb 8, 2024
1 parent 688296e commit bc51e70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/pages/leaderboards/[mode].astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ const { page = 1, query, faction, order } = Object.fromEntries(new URL(Astro.req
<div class="absolute inset-0 bg-gradient-to-b from-gray-950/60 to-gray-950"></div>
</div>
<section class="relative mx-auto max-w-screen-md space-y-4 px-4 py-0">
<Leaderboard mode={mode} query={query} faction={faction as Race} page={Number(page)} order={order as LeaderboardOrder} client:load />
<Leaderboard
mode={mode}
query={query}
faction={faction as Race}
page={Number(page)}
order={order as LeaderboardOrder}
client:load
/>
<EsoPromo />
</section>
</Layout>
12 changes: 8 additions & 4 deletions src/pages/players/[id]-[username].astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ const themes = {
type Theme = keyof typeof themes
const playerId = Astro.params.id!
const player = await PlayersApi.getPlayer({ playerId })
const playerMatches = await PlayersApi.getPlayerMatches({ playerId })
const playerRequest = PlayersApi.getPlayer({ playerId })
const playerMatchesRequest = PlayersApi.getPlayerMatches({ playerId })
const playerActivityRequest = PlayersApi.getPlayerStatisticsActivity({ playerId })
const player = await playerRequest
const playerMatches = await playerMatchesRequest
const playerActivity = await playerActivityRequest
const highestLeague = player.leaderboard_entries.reduce(
(acc, entry) => (entry.points > acc.points ? entry : acc),
player.leaderboard_entries[0]
)
const playerActivity = (await PlayersApi.getPlayerStatisticsActivity({ playerId })) as any as PlayerActivityStats
---

<Layout title={player.nickname}>
Expand Down

0 comments on commit bc51e70

Please sign in to comment.