fix: small bug

This commit is contained in:
Asher Samuel 2025-07-04 16:28:31 +03:00
parent 6a341da9b3
commit ddf55763d2
4 changed files with 8 additions and 7 deletions

View File

@ -116,7 +116,7 @@ WHERE bet_id = $1;
-- name: GetBetCount :one -- name: GetBetCount :one
SELECT COUNT(*) SELECT COUNT(*)
FROM bets FROM bets
where user_id = $1 WHERE user_id = $1
AND outcomes_hash = $2; AND outcomes_hash = $2;
-- name: UpdateCashOut :exec -- name: UpdateCashOut :exec
UPDATE bets UPDATE bets

View File

@ -135,6 +135,7 @@ func convertCreateBet(bet domain.CreateBet) dbgen.CreateBetParams {
}, },
IsShopBet: bet.IsShopBet, IsShopBet: bet.IsShopBet,
CashoutID: bet.CashoutID, CashoutID: bet.CashoutID,
OutcomesHash: bet.OutcomesHash,
FastCode: bet.FastCode, FastCode: bet.FastCode,
} }
} }
@ -294,7 +295,7 @@ func (s *Store) GetBetByFastCode(ctx context.Context, fastcode string) (domain.G
func (s *Store) GetBetCount(ctx context.Context, UserID int64, outcomesHash string) (int64, error) { func (s *Store) GetBetCount(ctx context.Context, UserID int64, outcomesHash string) (int64, error) {
count, err := s.queries.GetBetCount(ctx, dbgen.GetBetCountParams{ count, err := s.queries.GetBetCount(ctx, dbgen.GetBetCountParams{
UserID: pgtype.Int8{Int64: UserID}, UserID: pgtype.Int8{Int64: UserID, Valid: true},
OutcomesHash: outcomesHash, OutcomesHash: outcomesHash,
}) })

View File

@ -236,7 +236,7 @@ func (s *Service) PlaceBet(ctx context.Context, req domain.CreateBetReq, userID
if err != nil { if err != nil {
return domain.CreateBetRes{}, err return domain.CreateBetRes{}, err
} }
if count == 2 { if count >= 2 {
return domain.CreateBetRes{}, fmt.Errorf("bet already pleaced twice") return domain.CreateBetRes{}, fmt.Errorf("bet already pleaced twice")
} }

View File

@ -1,4 +1,4 @@
package odds package odds
import ( import (
"context" "context"