Skip to content

Commit

Permalink
throw 503 if strategy is not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkunz committed Jan 9, 2024
1 parent e44fd1c commit 6e58683
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Old path - read stats from the state
const oldLatestStats = getPortfolioLatestStats(state);
// New path - use server precalculated stats
const summaryStatistics = summary?.summary_statistics;
const summaryStatistics = summary.summary_statistics;
</script>

<section class="performance">
Expand Down
10 changes: 7 additions & 3 deletions src/routes/strategies/[strategy]/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ export async function load({ params, fetch }) {
const strategy = getConfiguredStrategyById(params.strategy);
if (!strategy) throw error(404, 'Not found');

const state = getStrategyState(fetch, strategy.id);
const summary = await getStrategyRuntimeState(strategy, fetch);
const chain_id = summary?.on_chain_data?.chain_id;
const chain = fetchPublicApi(fetch, 'chain-details', { chain_id });
if (!summary.connected) throw error(503, 'Service Unavailable');

const state = getStrategyState(fetch, strategy.id);

const chain = fetchPublicApi(fetch, 'chain-details', {
chain_id: summary.on_chain_data.chain_id.toString()
});

return { chain, strategy, summary, state };
}

0 comments on commit 6e58683

Please sign in to comment.