Fix error when 2 trade-id's collide in dashboard

This commit is contained in:
Matthias 2021-09-18 10:40:53 +02:00
parent d8d9caf9d9
commit 25e0bace6d
5 changed files with 15 additions and 6 deletions

View File

@ -11,7 +11,7 @@
:empty-text="emptyText" :empty-text="emptyText"
:per-page="perPage" :per-page="perPage"
:current-page="currentPage" :current-page="currentPage"
primary-key="trade_id" primary-key="botTradeId"
selectable selectable
select-mode="single" select-mode="single"
:filter="filterText" :filter="filterText"

View File

@ -92,7 +92,6 @@ export default function createBotStore(store) {
getters.allAvailableBotsList.forEach((botId) => { getters.allAvailableBotsList.forEach((botId) => {
const trades = getters[`${botId}/${BotStoreGetters.openTrades}`].map((t) => ({ const trades = getters[`${botId}/${BotStoreGetters.openTrades}`].map((t) => ({
...t, ...t,
botId,
})); }));
resp = resp.concat(trades); resp = resp.concat(trades);

View File

@ -514,6 +514,11 @@ export function createBotSubStore(botId: string) {
} while (trades.length !== totalTrades); } while (trades.length !== totalTrades);
} }
const tradesCount = trades.length; const tradesCount = trades.length;
// Add botId to all trades
trades = trades.map((t) => ({
...t,
botTradeId: `${botId}__${t.trade_id}`,
}));
commit('updateTrades', { trades, tradesCount }); commit('updateTrades', { trades, tradesCount });
return Promise.resolve(); return Promise.resolve();
} catch (error) { } catch (error) {
@ -564,7 +569,12 @@ export function createBotSubStore(botId: string) {
// dispatch('refreshSlow', null, { root: true }); // dispatch('refreshSlow', null, { root: true });
} }
commit('updateOpenTrades', result.data); const openTrades = result.data.map((t) => ({
...t,
botTradeId: `${botId}__${t.trade_id}`,
}));
commit('updateOpenTrades', openTrades);
}) })
.catch(console.error); .catch(console.error);
}, },

View File

@ -53,8 +53,8 @@ const DEFAULT_TRADING_LAYOUT: GridItemData[] = [
const DEFAULT_DASHBOARD_LAYOUT: GridItemData[] = [ const DEFAULT_DASHBOARD_LAYOUT: GridItemData[] = [
{ i: DashboardLayout.KPI, x: 0, y: 0, w: 4, h: 6 }, { i: DashboardLayout.KPI, x: 0, y: 0, w: 4, h: 6 },
{ i: DashboardLayout.dailyChart, x: 4, y: 0, w: 4, h: 6 }, { i: DashboardLayout.dailyChart, x: 4, y: 0, w: 4, h: 6 },
{ i: DashboardLayout.botComparison, x: 0, y: 6, w: 6, h: 4 } /* Bot Comparison */, { i: DashboardLayout.botComparison, x: 0, y: 6, w: 6, h: 6 } /* Bot Comparison */,
{ i: DashboardLayout.allOpenTrades, x: 6, y: 6, w: 6, h: 4 }, { i: DashboardLayout.allOpenTrades, x: 6, y: 6, w: 6, h: 6 },
{ i: DashboardLayout.cumChartChart, x: 8, y: 0, w: 4, h: 6 }, { i: DashboardLayout.cumChartChart, x: 8, y: 0, w: 4, h: 6 },
{ i: DashboardLayout.tradesLogChart, x: 0, y: 12, w: 12, h: 4 }, { i: DashboardLayout.tradesLogChart, x: 0, y: 12, w: 12, h: 4 },
]; ];

View File

@ -3,7 +3,7 @@ export interface Trade {
* BotId - only available on "all" methods. * BotId - only available on "all" methods.
* corresponds to the UI (ftbot.1) - does NOT relate to the backend * corresponds to the UI (ftbot.1) - does NOT relate to the backend
*/ */
botId: string; botTradeId: string;
trade_id: number; trade_id: number;
pair: string; pair: string;
is_open: boolean; is_open: boolean;