Skip to content

Commit

Permalink
loan history api 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
onaries committed Feb 10, 2024
1 parent c688145 commit f4f844d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,15 @@ async def get_loan_detail_history(id: int, db: Session = Depends(get_db)):
raise HTTPException(status_code=404, detail="Loan not found")

data = defaultdict(int)
prev_amount = -1
for history in loan.versions:
if history.updated_at is None:
data[history.created_at.strftime("%Y-%m-%d")] = history.amount
if history.amount != prev_amount:
data[history.created_at.strftime("%Y-%m-%d")] = history.amount

else:
data[history.updated_at.strftime("%Y-%m-%d")] = history.amount
if history.amount != prev_amount:
data[history.updated_at.strftime("%Y-%m-%d")] = history.amount

result = []
for k, v in data.items():
Expand Down

0 comments on commit f4f844d

Please sign in to comment.