Remove more usages of .query

This commit is contained in:
Matthias 2023-03-15 21:10:47 +01:00
parent d45599ca3b
commit 8073989c98
3 changed files with 5 additions and 10 deletions

View File

@ -819,7 +819,7 @@ class FreqtradeBot(LoggingMixin):
trade.orders.append(order_obj)
trade.recalc_trade_from_orders()
Trade.query.session.add(trade)
Trade._session.add(trade)
Trade.commit()
# Updating wallets

View File

@ -51,8 +51,8 @@ class PairLocks():
active=True
)
if PairLocks.use_db:
PairLock.query.session.add(lock)
PairLock.query.session.commit()
PairLock._session.add(lock)
PairLock._session.commit()
else:
PairLocks.locks.append(lock)
return lock
@ -106,7 +106,7 @@ class PairLocks():
for lock in locks:
lock.active = False
if PairLocks.use_db:
PairLock.query.session.commit()
PairLock._session.commit()
@staticmethod
def unlock_reason(reason: str, now: Optional[datetime] = None) -> None:
@ -130,7 +130,7 @@ class PairLocks():
for lock in locks:
logger.info(f"Releasing lock for {lock.pair} with reason '{reason}'.")
lock.active = False
PairLock.query.session.commit()
PairLock._session.commit()
else:
# used in backtesting mode; don't show log messages for speed
locksb = PairLocks.get_pair_locks(None)

View File

@ -347,11 +347,6 @@ class RPC:
Trade.close_date < (profitday + time_offset(1)))
.order_by(Trade.close_date)
).all()
# trades = Trade.query.session.query(Trade.close_profit_abs).filter(
# Trade.is_open.is_(False),
# Trade.close_date >= profitday,
# Trade.close_date < (profitday + time_offset(1))
# ).order_by(Trade.close_date).all()
curdayprofit = sum(
trade.close_profit_abs for trade in trades if trade.close_profit_abs is not None)