Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieay committed Jun 28, 2016
1 parent 689b341 commit 862577e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/view_models/winners_view_model.rb
Expand Up @@ -45,6 +45,14 @@ def average_winning_bid
end
end

def average_days_to_delivery
if auction_count > 0
HumanTime.new(time: (total_auction_delivery_time_length / auction_count)).distance_of_time
else
'n/a'
end
end

def small_business_count
User.where(small_business: true).count
end
Expand All @@ -57,6 +65,12 @@ def total_auction_time_length
end.reduce(:+)
end

def total_auction_delivery_time_length
completed_auctions.map do |auction|
auction.delivery_due_at - auction.ended_at
end.reduce(:+)
end

def total_winning_bid_amount
completed_auctions.map do |auction|
auction.lowest_bid.amount
Expand Down
6 changes: 6 additions & 0 deletions app/views/winners/index.html.erb
Expand Up @@ -45,6 +45,12 @@
statistic: @view_model.average_winning_bid,
label: 'average winning bid'
} %>
<%= render partial: 'hero_metric',
locals: {
href: '#chart-winning-bid',
statistic: @view_model.average_days_to_delivery,
label: 'average days to delivery'
} %>
<%= render partial: 'hero_metric',
locals: {
href: '#',
Expand Down

0 comments on commit 862577e

Please sign in to comment.