madness continues
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"synlotto-website/helpers"
|
||||
"synlotto-website/models"
|
||||
"synlotto-website/rules"
|
||||
draws "synlotto-website/services/draws"
|
||||
)
|
||||
|
||||
func RunTicketMatching(db *sql.DB, triggeredBy string) (models.MatchRunStats, error) {
|
||||
@@ -24,6 +25,9 @@ func RunTicketMatching(db *sql.DB, triggeredBy string) (models.MatchRunStats, er
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
// Buffer results to avoid writing while iterating
|
||||
var pending []models.Ticket
|
||||
|
||||
for rows.Next() {
|
||||
var t models.Ticket
|
||||
var b1, b2, b3, b4, b5, b6, bo1, bo2 sql.NullInt64
|
||||
@@ -45,6 +49,10 @@ func RunTicketMatching(db *sql.DB, triggeredBy string) (models.MatchRunStats, er
|
||||
t.Bonus1 = helpers.IntPtrIfValid(bo1)
|
||||
t.Bonus2 = helpers.IntPtrIfValid(bo2)
|
||||
|
||||
pending = append(pending, t)
|
||||
}
|
||||
|
||||
for _, t := range pending {
|
||||
matchTicket := models.MatchTicket{
|
||||
ID: t.Id,
|
||||
GameType: t.GameType,
|
||||
@@ -53,14 +61,14 @@ func RunTicketMatching(db *sql.DB, triggeredBy string) (models.MatchRunStats, er
|
||||
BonusBalls: helpers.BuildBonusSlice(t),
|
||||
}
|
||||
|
||||
draw := GetDrawResultForTicket(db, t.GameType, t.DrawDate)
|
||||
draw := draws.GetDrawResultForTicket(db, t.GameType, t.DrawDate)
|
||||
result := handlers.MatchTicketToDraw(matchTicket, draw, rules.ThunderballPrizeRules)
|
||||
|
||||
if result.MatchedDrawID == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = db.Exec(`
|
||||
_, err := db.Exec(`
|
||||
UPDATE my_tickets
|
||||
SET matched_main = ?, matched_bonus = ?, prize_tier = ?, is_winner = ?
|
||||
WHERE id = ?
|
||||
|
||||
Reference in New Issue
Block a user