Working through issue where prizes are incorrect and need updating.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package helpers
|
||||
|
||||
import "synlotto-website/models"
|
||||
import (
|
||||
"database/sql"
|
||||
"synlotto-website/models"
|
||||
)
|
||||
|
||||
func BuildBallsSlice(t models.Ticket) []int {
|
||||
balls := []int{t.Ball1, t.Ball2, t.Ball3, t.Ball4, t.Ball5}
|
||||
@@ -22,3 +25,26 @@ func BuildBonusSlice(t models.Ticket) []int {
|
||||
|
||||
return bonuses
|
||||
}
|
||||
|
||||
// BuildBallsFromNulls builds main balls from sql.NullInt64 values
|
||||
func BuildBallsFromNulls(vals ...sql.NullInt64) []int {
|
||||
var result []int
|
||||
for _, v := range vals {
|
||||
if v.Valid {
|
||||
result = append(result, int(v.Int64))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// BuildBonusFromNulls builds bonus balls from two sql.NullInt64 values
|
||||
func BuildBonusFromNulls(b1, b2 sql.NullInt64) []int {
|
||||
var result []int
|
||||
if b1.Valid {
|
||||
result = append(result, int(b1.Int64))
|
||||
}
|
||||
if b2.Valid {
|
||||
result = append(result, int(b2.Int64))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user