Improve performance of some RPC calls

These don't need orders to be loaded. As a side-effect, this will
also reduce the strain on the database.
This commit is contained in:
Matthias
2022-06-19 16:13:00 +02:00
parent 0809f9aef6
commit 0d967f93ba
3 changed files with 30 additions and 6 deletions

View File

@@ -2075,6 +2075,24 @@ def test_get_trades_proxy(fee, use_db, is_short):
Trade.use_db = True
@pytest.mark.usefixtures("init_persistence")
@pytest.mark.parametrize('is_short', [True, False])
def test_get_trades__query(fee, is_short):
query = Trade.get_trades([])
# without orders there should be no join issued.
query1 = Trade.get_trades([], include_orders=False)
assert "JOIN orders" in str(query)
assert "JOIN orders" not in str(query1)
create_mock_trades(fee, is_short)
query = Trade.get_trades([])
query1 = Trade.get_trades([], include_orders=False)
assert "JOIN orders" in str(query)
assert "JOIN orders" not in str(query1)
def test_get_trades_backtest():
Trade.use_db = False
with pytest.raises(NotImplementedError, match=r"`Trade.get_trades\(\)` not .*"):