Skip to content

Commit

Permalink
Merge pull request #1397 from glogiotatidis/issue-1396
Browse files Browse the repository at this point in the history
[Fix #1396] Handle zero impressions gracefully.
  • Loading branch information
glogiotatidis committed Jun 18, 2020
2 parents 34e6e9a + b9a85b6 commit 052b732
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions snippets/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2290,14 +2290,20 @@ def calculate_adj_impression(self):

@property
def adj_block_rate(self):
if self.adj_impression == 0:
return 'N/A'
return float(f'{(self.block / self.adj_impression) * 100:.4f}')

@property
def adj_click_rate(self):
if self.adj_impression == 0:
return 'N/A'
return float(f'{(self.click / self.adj_impression) * 100:.4f}')

@property
def click_rate(self):
if self.impression == 0:
return 'N/A'
return float(f'{(self.click / self.impression) * 100:.4f}')


Expand Down

0 comments on commit 052b732

Please sign in to comment.