Skip to content

Commit

Permalink
Merge pull request #121 from bramley/divide_by_zero
Browse files Browse the repository at this point in the history
Avoid divide by zero error in the Last Campaign Results widget
  • Loading branch information
michield authored Sep 14, 2021
2 parents d46fabb + 8c72c07 commit e5922e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pages/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</p>

<p><span class="total"><?php echo number_format($lastcampaign['total']) ?></span> Messages sent on <span class="total"><?php echo $lastcampaign['sent'] ?></span>.</p>
<p><span class="total"><?php echo number_format($lastcampaign['views']) ?> </span> Viewed (<span class="total"><?php echo sprintf('%0.2f', ($lastcampaign['views'] / ($lastcampaign['total'] - $lastcampaign['bounced']) * 100)) ?>%</span>), and <span class="total"><?php echo $lastcampaign['bounced'] ?></span> bounced (<span class="total"><?php echo sprintf('%0.2f', ($lastcampaign['bounced'] / $lastcampaign['total'] * 100)) ?>%</span>).</p>
<p><span class="total"><?php echo number_format($lastcampaign['views']) ?> </span> Viewed (<span class="total"><?php echo sprintf('%0.2f', ($lastcampaign['views'] / max(1, $lastcampaign['total'] - $lastcampaign['bounced']) * 100)) ?>%</span>), and <span class="total"><?php echo $lastcampaign['bounced'] ?></span> bounced (<span class="total"><?php echo sprintf('%0.2f', ($lastcampaign['bounced'] / max(1, $lastcampaign['total']) * 100)) ?>%</span>).</p>

<?php
} ?>
Expand Down

0 comments on commit e5922e4

Please sign in to comment.