core/internal/adapter/bun_utils.go

26 lines
620 B
Go

package adapter
import "github.com/uptrace/bun"
func appendODSetClauses(q *bun.InsertQuery) *bun.InsertQuery {
return q.Set("rank_att = EXCLUDED.rank_att").
Set("score_att = EXCLUDED.score_att").
Set("rank_def = EXCLUDED.rank_def").
Set("score_def = EXCLUDED.score_def").
Set("rank_sup = EXCLUDED.rank_sup").
Set("score_sup = EXCLUDED.score_sup").
Set("rank_total = EXCLUDED.rank_total").
Set("score_total = EXCLUDED.score_total")
}
func separateListResultAndNext[T any](res []T, limit int) ([]T, T) {
var next T
if len(res) > limit {
next = res[limit]
res = res[:limit]
}
return res, next
}