Skip to content

Commit

Permalink
fix billing total pages and count (#3709)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 authored Aug 18, 2023
1 parent 32f3843 commit 016c05e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/pkg/database/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ func (m *MongoDB) queryBillingRecordsByOrderID(billingRecordQuery *accountv1.Bil
}

billingRecordQuery.Status.Items = billingRecords
billingRecordQuery.Status.PageLength = 1
billingRecordQuery.Status.TotalCount = len(billingRecords)
return nil
}

Expand Down Expand Up @@ -530,6 +532,10 @@ func (m *MongoDB) QueryBillingRecords(billingRecordQuery *accountv1.BillingRecor
}

totalPages := (totalCount + billingRecordQuery.Spec.PageSize - 1) / billingRecordQuery.Spec.PageSize
if totalCount == 0 {
totalPages = 1
totalCount = len(billingRecords)
}
billingRecordQuery.Status.Items, billingRecordQuery.Status.PageLength, billingRecordQuery.Status.TotalCount,
billingRecordQuery.Status.RechargeAmount, billingRecordQuery.Status.DeductionAmount = billingRecords, totalPages, totalCount, totalRechargeAmount, totalDeductionAmount
return nil
Expand Down

0 comments on commit 016c05e

Please sign in to comment.