Bid.get_delta_amount refactor

master
E. Almqvist 3 years ago
parent 2850f07c9f
commit 816f9ce80f
  1. 9
      src/lib/db_models.rb

@ -462,11 +462,14 @@ class Bid < EntityModel
def self.get_delta_amount(ahid, uid, amount)
data = self.get "*", "auction_id = ?, user_id = ?", ahid, uid
data && data.map! {|dat| self.new(dat)}
p data
if data then
data.map! {|dat| self.new(dat)}
max_bid = data.max_by {|bid| bid.amount}
return amount - max_bid
else
return amount
end
end
def self.validate_bid(ahid, uid, amount, message)
ah = Auction.find_by_id ahid

Loading…
Cancel
Save