Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Dec 23, 2023
1 parent dcf1985 commit b3fe496
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/api/endpoints/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
7 changes: 5 additions & 2 deletions app/db/models/transferhistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3fe496

Please sign in to comment.