Skip to content

Commit

Permalink
perf: move epochs query to local router from edge (#3751)
Browse files Browse the repository at this point in the history
* perf: move epochs query to local router from edge

* stale while revalidate
  • Loading branch information
p0mvn authored Aug 18, 2024
1 parent 608eb8c commit 54123a4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/server/src/queries/complex/osmosis/epochs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export function getEpochs({
return cachified({
cache: epochsCache,
key: "epochs",
ttl: 1000 * 60, // 60 seconds
ttl: 1000 * 60 * 3, // 3 minutes
staleWhileRevalidate: 500, // Return stale data for 500ms while revalidating
getFreshValue: () =>
queryEpochs({ chainList }).then(({ epochs }) =>
epochs.map((e) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/overview/pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const PoolsOverview: FunctionComponent<
coinMinimalDenom: "uosmo",
}
);
const { data: epochs } = api.edge.params.getEpochs.useQuery();
const { data: epochs } = api.local.params.getEpochs.useQuery();

// update time every second
const [timeRemaining, setTimeRemaining] = useState<string | null>(null);
Expand Down
2 changes: 0 additions & 2 deletions packages/web/server/api/edge-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
createTRPCRouter,
earnRouter,
orderbookRouter,
paramsRouter,
poolsRouter,
stakingRouter,
transactionsRouter,
Expand All @@ -19,5 +18,4 @@ export const edgeRouter = createTRPCRouter({
transactions: transactionsRouter,
orderbooks: orderbookRouter,
chains: chainsRouter,
params: paramsRouter,
});
2 changes: 2 additions & 0 deletions packages/web/server/api/local-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
concentratedLiquidityRouter,
createTRPCRouter,
oneClickTradingRouter,
paramsRouter,
portfolioRouter,
swapRouter,
} from "@osmosis-labs/trpc";
Expand All @@ -21,4 +22,5 @@ export const localRouter = createTRPCRouter({
cms: cmsRouter,
bridgeTransfer: localBridgeTransferRouter,
portfolio: portfolioRouter,
params: paramsRouter,
});

0 comments on commit 54123a4

Please sign in to comment.