mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-13 03:33:50 +00:00
extract pagelength for trades request
This commit is contained in:
parent
33ea51b244
commit
2af9aeb28a
|
@ -198,17 +198,20 @@ export default {
|
||||||
async getTrades({ commit }) {
|
async getTrades({ commit }) {
|
||||||
try {
|
try {
|
||||||
let totalTrades = 0;
|
let totalTrades = 0;
|
||||||
|
const pageLength = 500;
|
||||||
const fetchTrades = async (limit: number, offset: number) => {
|
const fetchTrades = async (limit: number, offset: number) => {
|
||||||
return api.get('/trades', { params: { limit, offset } });
|
return api.get('/trades', { params: { limit, offset } });
|
||||||
};
|
};
|
||||||
const res = await fetchTrades(500, 0);
|
const res = await fetchTrades(pageLength, 0);
|
||||||
const result: TradeResponse = res.data;
|
const result: TradeResponse = res.data;
|
||||||
let { trades } = result;
|
let { trades } = result;
|
||||||
if (trades.length !== result.total_trades) {
|
if (trades.length !== result.total_trades) {
|
||||||
// Pagination necessary
|
// Pagination necessary
|
||||||
|
// Don't use Promise.all - this would fire all requests at once, which can
|
||||||
|
// cause problems for big sqlite databases
|
||||||
do {
|
do {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const res = await fetchTrades(500, trades.length);
|
const res = await fetchTrades(pageLength, trades.length);
|
||||||
|
|
||||||
const result: TradeResponse = res.data;
|
const result: TradeResponse = res.data;
|
||||||
trades = trades.concat(result.trades);
|
trades = trades.concat(result.trades);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user