commit 0bb1aaf5e57a4739412fad3f3cccfffbddb1320c
parent ddb458e3d2e25caf83afde7e3676f65347951814
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 15 Dec 2023 22:30:49 -0500
cleanup
Diffstat:
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/pkg/database/tablePokerTables.go b/pkg/database/tablePokerTables.go
@@ -68,12 +68,6 @@ func (a *PokerTableAccount) DoSave(db *DkfDB) {
}
}
-func (a *PokerTableAccount) RefundBetAndSave(db *DkfDB) {
- a.Amount += a.AmountBet
- a.AmountBet = 0
- a.DoSave(db)
-}
-
func (d *DkfDB) GetPositivePokerTableAccounts() (out []PokerTableAccount, err error) {
err = d.db.Preload("PokerTable").Find(&out, "amount > 0 OR amount_bet > 0").Error
return
@@ -92,3 +86,9 @@ func (d *DkfDB) PokerTableAccountBet(userID UserID, pokerTableID int64, bet Poke
bet, bet, userID, pokerTableID).Error
return
}
+
+func (d *DkfDB) PokerTableAccountRefundBet(userID UserID, pokerTableID int64) (err error) {
+ err = d.db.Exec(`UPDATE poker_table_accounts SET amount = amount + amount_bet, amount_bet = 0 WHERE user_id = ? AND poker_table_id = ?`,
+ userID, pokerTableID).Error
+ return
+}
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -939,8 +939,7 @@ END:
// No winners, refund bets
tx := db.Begin()
for _, op := range g.Ongoing.Players {
- account, _ := tx.GetPokerTableAccount(op.UserID, g.PokerTableID)
- account.RefundBetAndSave(tx)
+ _ = tx.PokerTableAccountRefundBet(op.UserID, g.PokerTableID)
}
tx.Commit()
}