Skip to content

Commit

Permalink
fix: Prevent division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 30, 2024
1 parent ac9ec07 commit a929483
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/utils/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ def get_general_statistics(
Application.status == ApplicationStatus.APPROVED
).count()

if application_received_count:
column = Application.borrower_accepted_at if lender_id is None else Application.borrower_submitted_at
column = Application.borrower_accepted_at if lender_id is None else Application.borrower_submitted_at
application_submitted_count = session.query(Application).filter(col(column).isnot(None)).count()
if application_submitted_count:
proportion_of_submitted_out_of_opt_in = round(
(application_received_count / session.query(Application).filter(col(column).isnot(None)).count()) * 100, 2
(application_received_count / application_submitted_count) * 100, 2
)
else:
proportion_of_submitted_out_of_opt_in = 0.0
Expand Down

0 comments on commit a929483

Please sign in to comment.