package services // ToDo: these aren't really "services" import ( "database/sql" "log" "synlotto-website/internal/models" ) func GetDrawResultForTicket(db *sql.DB, game string, drawDate string) models.DrawResult { var result models.DrawResult if game != "Thunderball" { log.Printf("Draw lookup for unsupported game type: %s", game) return result } query := ` SELECT id, ball1, ball2, ball3, ball4, ball5, thunderball FROM results_thunderball WHERE draw_date = ? ` var b1, b2, b3, b4, b5, tb sql.NullInt64 err := db.QueryRow(query, drawDate).Scan(&result.DrawID, &b1, &b2, &b3, &b4, &b5, &tb) if err != nil { log.Printf("No draw found for %s %s: %v", game, drawDate, err) return result } result.GameType = game result.DrawDate = drawDate result.Balls = []int{int(b1.Int64), int(b2.Int64), int(b3.Int64), int(b4.Int64), int(b5.Int64)} if tb.Valid { result.BonusBalls = []int{int(tb.Int64)} } return result }