Processing new bid MQTT messages
This commit is contained in:
@@ -52,6 +52,19 @@ class AuctionsDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvid
|
||||
.map(_ == 1)
|
||||
}
|
||||
|
||||
def find_by_gid(gid: String): Future[Option[Auction]] = {
|
||||
db.run(Auctions.filter(_.gid === gid).take(1).result.headOption)
|
||||
}
|
||||
|
||||
def newBid(auction: Auction, bidder: User, bid: BigDecimal, timestamp: Instant): Future[Option[Auction]] = {
|
||||
db.run {
|
||||
Auctions.filter(_.id === auction.id.get).map{ it => (it.currentBid, it.currentBidAt, it.currentBidderId) }
|
||||
.update((Some(bid), Some(timestamp), Some(bidder.id.get)))
|
||||
.andThen { Auctions.filter(_.id === auction.id.get).result.headOption }
|
||||
.transactionally
|
||||
}
|
||||
}
|
||||
|
||||
private def availableScope(user: User) = {
|
||||
Auctions.filter(row => (row.status === AuctionStatus.Ready) && (row.authorId =!= user.id.get))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user