Skip to content

Commit

Permalink
fix #258
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 1, 2024
1 parent be1ceb9 commit ca0fcb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions auctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,25 @@ def lots_qs(self):
def total_sold_lots(self):
return self.lots_qs.filter(winning_price__isnull=False).exclude(banned=True).count()

@property
def total_sold_lots_with_buy_now_percent(self):
if not self.total_sold_lots:
return 0
if self.is_online:
return (
self.lots_qs.filter(winning_price__isnull=False, buy_now_used=True).exclude(banned=True).count()
/ self.total_sold_lots
* 100
)
else:
return (
self.lots_qs.filter(winning_price__isnull=False, winning_price=F("buy_now_price"))
.exclude(banned=True)
.count()
/ self.total_sold_lots
* 100
)

@property
def total_unsold_lots(self):
return self.lots_qs.filter(winning_price__isnull=True).exclude(banned=True).count()
Expand Down
2 changes: 1 addition & 1 deletion auctions/templates/auction_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h4>User engagement</h4>
</tr>

<tr>
<td>Sold lots</td><td>{{auction.total_sold_lots}}</td>
<td>Sold lots</td><td>{{auction.total_sold_lots}} ({{ auction.total_sold_lots_with_buy_now_percent|floatformat:0 }}% with buy now)</td>
</tr>
<tr>
<td>Median lot price</td><td>${{auction.median_lot_price|floatformat:2}}</td>
Expand Down

0 comments on commit ca0fcb4

Please sign in to comment.