Skip to content

Commit

Permalink
fix: possible division by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ellite committed May 17, 2024
1 parent 7f38366 commit 34493f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ function getPriceConverted($price, $currency, $database) {
$totalCostPerYear = $totalCostPerMonth * 12;

// Calculate average subscription monthly cost
$averageSubscriptionCost = $totalCostPerMonth / $activeSubscriptions;
if ($activeSubscriptions > 0) {
$averageSubscriptionCost = $totalCostPerMonth / $activeSubscriptions;
} else {
$totalCostPerYear = 0;
$averageSubscriptionCost = 0;
}
} else {
$totalCostPerYear = 0;
$averageSubscriptionCost = 0;
Expand Down

0 comments on commit 34493f7

Please sign in to comment.