diff --git a/app/api/endpoints/history.py b/app/api/endpoints/history.py index 18104ed9e..63f64d07a 100644 --- a/app/api/endpoints/history.py +++ b/app/api/endpoints/history.py @@ -61,7 +61,7 @@ def transfer_history(title: str = None, count=count, status=status) else: result = TransferHistory.list_by_page(db, page=page, count=count, status=status) - total = TransferHistory.count(db) + total = TransferHistory.count(db, status=status) return schemas.Response(success=True, data={ diff --git a/app/db/models/transferhistory.py b/app/db/models/transferhistory.py index 0b246a4a7..4e6834a30 100644 --- a/app/db/models/transferhistory.py +++ b/app/db/models/transferhistory.py @@ -103,8 +103,11 @@ def statistic(db: Session, days: int = 7): @staticmethod @db_query - def count(db: Session): - return db.query(func.count(TransferHistory.id)).first()[0] + def count(db: Session, status: bool = None): + if status is not None: + return db.query(func.count(TransferHistory.id)).filter(TransferHistory.status == status).first()[0] + else: + return db.query(func.count(TransferHistory.id)).first()[0] @staticmethod @db_query