mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-22 19:15:15 +00:00
fix bug in fetch logic
This commit is contained in:
parent
bc7f21eaff
commit
c385d7a097
|
@ -256,30 +256,31 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
const res = await fetchTrades(pageLength, 0);
|
||||
const result: TradeResponse = res.data;
|
||||
let { trades } = result;
|
||||
if (Array.isArray(trades) && trades.length !== result.total_trades) {
|
||||
// Pagination necessary
|
||||
// Don't use Promise.all - this would fire all requests at once, which can
|
||||
// cause problems for big sqlite databases
|
||||
do {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const res = await fetchTrades(pageLength, trades.length);
|
||||
if (Array.isArray(trades)) {
|
||||
if (trades.length !== result.total_trades) {
|
||||
// Pagination necessary
|
||||
// Don't use Promise.all - this would fire all requests at once, which can
|
||||
// cause problems for big sqlite databases
|
||||
do {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const res = await fetchTrades(pageLength, trades.length);
|
||||
|
||||
const result: TradeResponse = res.data;
|
||||
trades = trades.concat(result.trades);
|
||||
totalTrades = res.data.total_trades;
|
||||
} while (trades.length !== totalTrades);
|
||||
const result: TradeResponse = res.data;
|
||||
trades = trades.concat(result.trades);
|
||||
totalTrades = res.data.total_trades;
|
||||
} while (trades.length !== totalTrades);
|
||||
}
|
||||
const tradesCount = trades.length;
|
||||
// Add botId to all trades
|
||||
trades = trades.map((t) => ({
|
||||
...t,
|
||||
botId,
|
||||
botName,
|
||||
botTradeId: `${botId}__${t.trade_id}`,
|
||||
}));
|
||||
this.trades = trades;
|
||||
this.tradeCount = tradesCount;
|
||||
}
|
||||
const tradesCount = trades.length;
|
||||
// Add botId to all trades
|
||||
trades = trades.map((t) => ({
|
||||
...t,
|
||||
botId,
|
||||
botName,
|
||||
botTradeId: `${botId}__${t.trade_id}`,
|
||||
}));
|
||||
this.trades = trades;
|
||||
this.tradeCount = tradesCount;
|
||||
|
||||
return Promise.resolve();
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -305,14 +306,15 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
this.refreshRequired = true;
|
||||
this.refreshSlow(false);
|
||||
}
|
||||
|
||||
const openTrades = result.data.map((t) => ({
|
||||
...t,
|
||||
botId,
|
||||
botName,
|
||||
botTradeId: `${botId}__${t.trade_id}`,
|
||||
}));
|
||||
this.openTrades = openTrades;
|
||||
if (Array.isArray(result.data)) {
|
||||
const openTrades = result.data.map((t) => ({
|
||||
...t,
|
||||
botId,
|
||||
botName,
|
||||
botTradeId: `${botId}__${t.trade_id}`,
|
||||
}));
|
||||
this.openTrades = openTrades;
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user