feat: api - GET /api/v2/versions/{versionCode}/servers/{serverKey}/players - new sort option
This commit is contained in:
parent
c4d8a380c3
commit
82d313d2ae
|
@ -1162,6 +1162,8 @@ components:
|
||||||
- odScoreAtt:DESC
|
- odScoreAtt:DESC
|
||||||
- odScoreDef:ASC
|
- odScoreDef:ASC
|
||||||
- odScoreDef:DESC
|
- odScoreDef:DESC
|
||||||
|
- odScoreSup:ASC
|
||||||
|
- odScoreSup:DESC
|
||||||
- odScoreTotal:ASC
|
- odScoreTotal:ASC
|
||||||
- odScoreTotal:DESC
|
- odScoreTotal:DESC
|
||||||
- points:ASC
|
- points:ASC
|
||||||
|
|
|
@ -198,6 +198,10 @@ func (a listPlayersParamsApplier) apply(q *bun.SelectQuery) *bun.SelectQuery {
|
||||||
q = q.Order("player.score_def ASC")
|
q = q.Order("player.score_def ASC")
|
||||||
case domain.PlayerSortODScoreDefDESC:
|
case domain.PlayerSortODScoreDefDESC:
|
||||||
q = q.Order("player.score_def DESC")
|
q = q.Order("player.score_def DESC")
|
||||||
|
case domain.PlayerSortODScoreSupASC:
|
||||||
|
q = q.Order("player.score_sup ASC")
|
||||||
|
case domain.PlayerSortODScoreSupDESC:
|
||||||
|
q = q.Order("player.score_sup DESC")
|
||||||
case domain.PlayerSortODScoreTotalASC:
|
case domain.PlayerSortODScoreTotalASC:
|
||||||
q = q.Order("player.score_total ASC")
|
q = q.Order("player.score_total ASC")
|
||||||
case domain.PlayerSortODScoreTotalDESC:
|
case domain.PlayerSortODScoreTotalDESC:
|
||||||
|
@ -247,62 +251,58 @@ func (a listPlayersParamsApplier) applyCursor(q *bun.SelectQuery) *bun.SelectQue
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortServerKeyASC:
|
case domain.PlayerSortServerKeyASC:
|
||||||
el.value = cursor.ServerKey()
|
el.value = cursor.ServerKey()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.server_key"
|
el.column = "player.server_key"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortServerKeyDESC:
|
case domain.PlayerSortServerKeyDESC:
|
||||||
el.value = cursor.ServerKey()
|
el.value = cursor.ServerKey()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.server_key"
|
el.column = "player.server_key"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortODScoreAttASC:
|
case domain.PlayerSortODScoreAttASC:
|
||||||
el.value = cursor.ODScoreAtt()
|
el.value = cursor.ODScoreAtt()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_att"
|
el.column = "player.score_att"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortODScoreAttDESC:
|
case domain.PlayerSortODScoreAttDESC:
|
||||||
el.value = cursor.ODScoreAtt()
|
el.value = cursor.ODScoreAtt()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_att"
|
el.column = "player.score_att"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortODScoreDefASC:
|
case domain.PlayerSortODScoreDefASC:
|
||||||
el.value = cursor.ODScoreDef()
|
el.value = cursor.ODScoreDef()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_def"
|
el.column = "player.score_def"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortODScoreDefDESC:
|
case domain.PlayerSortODScoreDefDESC:
|
||||||
el.value = cursor.ODScoreDef()
|
el.value = cursor.ODScoreDef()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_def"
|
el.column = "player.score_def"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
|
case domain.PlayerSortODScoreSupASC:
|
||||||
|
el.value = cursor.ODScoreSup()
|
||||||
|
el.column = "player.score_sup"
|
||||||
|
el.direction = sortDirectionASC
|
||||||
|
case domain.PlayerSortODScoreSupDESC:
|
||||||
|
el.value = cursor.ODScoreSup()
|
||||||
|
el.column = "player.score_sup"
|
||||||
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortODScoreTotalASC:
|
case domain.PlayerSortODScoreTotalASC:
|
||||||
el.value = cursor.ODScoreTotal()
|
el.value = cursor.ODScoreTotal()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_total"
|
el.column = "player.score_total"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortODScoreTotalDESC:
|
case domain.PlayerSortODScoreTotalDESC:
|
||||||
el.value = cursor.ODScoreTotal()
|
el.value = cursor.ODScoreTotal()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.score_total"
|
el.column = "player.score_total"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortPointsASC:
|
case domain.PlayerSortPointsASC:
|
||||||
el.value = cursor.Points()
|
el.value = cursor.Points()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.points"
|
el.column = "player.points"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortPointsDESC:
|
case domain.PlayerSortPointsDESC:
|
||||||
el.value = cursor.Points()
|
el.value = cursor.Points()
|
||||||
el.unique = false
|
|
||||||
el.column = "player.points"
|
el.column = "player.points"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.PlayerSortDeletedAtASC:
|
case domain.PlayerSortDeletedAtASC:
|
||||||
el.value = cursor.DeletedAt()
|
el.value = cursor.DeletedAt()
|
||||||
el.unique = false
|
|
||||||
el.column = "COALESCE(player.deleted_at, '0001-01-01 00:00:00+00:00')"
|
el.column = "COALESCE(player.deleted_at, '0001-01-01 00:00:00+00:00')"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.PlayerSortDeletedAtDESC:
|
case domain.PlayerSortDeletedAtDESC:
|
||||||
el.value = cursor.DeletedAt()
|
el.value = cursor.DeletedAt()
|
||||||
el.unique = false
|
|
||||||
el.column = "COALESCE(player.deleted_at, '0001-01-01 00:00:00+00:00')"
|
el.column = "COALESCE(player.deleted_at, '0001-01-01 00:00:00+00:00')"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -248,72 +248,58 @@ func (a listTribesParamsApplier) applyCursor(q *bun.SelectQuery) *bun.SelectQuer
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortServerKeyASC:
|
case domain.TribeSortServerKeyASC:
|
||||||
el.value = cursor.ServerKey()
|
el.value = cursor.ServerKey()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.server_key"
|
el.column = "tribe.server_key"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortServerKeyDESC:
|
case domain.TribeSortServerKeyDESC:
|
||||||
el.value = cursor.ServerKey()
|
el.value = cursor.ServerKey()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.server_key"
|
el.column = "tribe.server_key"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortODScoreAttASC:
|
case domain.TribeSortODScoreAttASC:
|
||||||
el.value = cursor.ODScoreAtt()
|
el.value = cursor.ODScoreAtt()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_att"
|
el.column = "tribe.score_att"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortODScoreAttDESC:
|
case domain.TribeSortODScoreAttDESC:
|
||||||
el.value = cursor.ODScoreAtt()
|
el.value = cursor.ODScoreAtt()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_att"
|
el.column = "tribe.score_att"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortODScoreDefASC:
|
case domain.TribeSortODScoreDefASC:
|
||||||
el.value = cursor.ODScoreDef()
|
el.value = cursor.ODScoreDef()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_def"
|
el.column = "tribe.score_def"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortODScoreDefDESC:
|
case domain.TribeSortODScoreDefDESC:
|
||||||
el.value = cursor.ODScoreDef()
|
el.value = cursor.ODScoreDef()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_def"
|
el.column = "tribe.score_def"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortODScoreTotalASC:
|
case domain.TribeSortODScoreTotalASC:
|
||||||
el.value = cursor.ODScoreTotal()
|
el.value = cursor.ODScoreTotal()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_total"
|
el.column = "tribe.score_total"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortODScoreTotalDESC:
|
case domain.TribeSortODScoreTotalDESC:
|
||||||
el.value = cursor.ODScoreTotal()
|
el.value = cursor.ODScoreTotal()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.score_total"
|
el.column = "tribe.score_total"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortPointsASC:
|
case domain.TribeSortPointsASC:
|
||||||
el.value = cursor.Points()
|
el.value = cursor.Points()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.points"
|
el.column = "tribe.points"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortPointsDESC:
|
case domain.TribeSortPointsDESC:
|
||||||
el.value = cursor.Points()
|
el.value = cursor.Points()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.points"
|
el.column = "tribe.points"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortDominanceASC:
|
case domain.TribeSortDominanceASC:
|
||||||
el.value = cursor.Dominance()
|
el.value = cursor.Dominance()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.dominance"
|
el.column = "tribe.dominance"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortDominanceDESC:
|
case domain.TribeSortDominanceDESC:
|
||||||
el.value = cursor.Dominance()
|
el.value = cursor.Dominance()
|
||||||
el.unique = false
|
|
||||||
el.column = "tribe.dominance"
|
el.column = "tribe.dominance"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
case domain.TribeSortDeletedAtASC:
|
case domain.TribeSortDeletedAtASC:
|
||||||
el.value = cursor.DeletedAt()
|
el.value = cursor.DeletedAt()
|
||||||
el.unique = false
|
|
||||||
el.column = "COALESCE(tribe.deleted_at, '0001-01-01 00:00:00+00:00')"
|
el.column = "COALESCE(tribe.deleted_at, '0001-01-01 00:00:00+00:00')"
|
||||||
el.direction = sortDirectionASC
|
el.direction = sortDirectionASC
|
||||||
case domain.TribeSortDeletedAtDESC:
|
case domain.TribeSortDeletedAtDESC:
|
||||||
el.value = cursor.DeletedAt()
|
el.value = cursor.DeletedAt()
|
||||||
el.unique = false
|
|
||||||
el.column = "COALESCE(tribe.deleted_at, '0001-01-01 00:00:00+00:00')"
|
el.column = "COALESCE(tribe.deleted_at, '0001-01-01 00:00:00+00:00')"
|
||||||
el.direction = sortDirectionDESC
|
el.direction = sortDirectionDESC
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -217,6 +217,35 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "OK: sort=[scoreSup DESC, serverKey ASC, id ASC]",
|
||||||
|
params: func(t *testing.T) domain.ListPlayersParams {
|
||||||
|
t.Helper()
|
||||||
|
params := domain.NewListPlayersParams()
|
||||||
|
require.NoError(t, params.SetSort([]domain.PlayerSort{
|
||||||
|
domain.PlayerSortODScoreSupDESC,
|
||||||
|
domain.PlayerSortServerKeyASC,
|
||||||
|
domain.PlayerSortIDASC,
|
||||||
|
}))
|
||||||
|
return params
|
||||||
|
},
|
||||||
|
assertResult: func(t *testing.T, _ domain.ListPlayersParams, res domain.ListPlayersResult) {
|
||||||
|
t.Helper()
|
||||||
|
players := res.Players()
|
||||||
|
assert.NotEmpty(t, len(players))
|
||||||
|
assert.True(t, slices.IsSortedFunc(players, func(a, b domain.Player) int {
|
||||||
|
return cmp.Or(
|
||||||
|
cmp.Compare(a.OD().ScoreSup(), b.OD().ScoreSup())*-1,
|
||||||
|
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||||
|
cmp.Compare(a.ID(), b.ID()),
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
assertError: func(t *testing.T, err error) {
|
||||||
|
t.Helper()
|
||||||
|
require.NoError(t, err)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "OK: sort=[scoreTotal DESC, serverKey ASC, id ASC]",
|
name: "OK: sort=[scoreTotal DESC, serverKey ASC, id ASC]",
|
||||||
params: func(t *testing.T) domain.ListPlayersParams {
|
params: func(t *testing.T) domain.ListPlayersParams {
|
||||||
|
|
|
@ -14,6 +14,7 @@ type PlayerCursorConfig struct {
|
||||||
ServerKey string
|
ServerKey string
|
||||||
ODScoreAtt int
|
ODScoreAtt int
|
||||||
ODScoreDef int
|
ODScoreDef int
|
||||||
|
ODScoreSup int
|
||||||
ODScoreTotal int
|
ODScoreTotal int
|
||||||
Points int
|
Points int
|
||||||
DeletedAt time.Time
|
DeletedAt time.Time
|
||||||
|
@ -27,6 +28,7 @@ func NewPlayerCursor(tb TestingTB, opts ...func(cfg *PlayerCursorConfig)) domain
|
||||||
ServerKey: RandServerKey(),
|
ServerKey: RandServerKey(),
|
||||||
ODScoreAtt: gofakeit.IntRange(0, math.MaxInt),
|
ODScoreAtt: gofakeit.IntRange(0, math.MaxInt),
|
||||||
ODScoreDef: gofakeit.IntRange(0, math.MaxInt),
|
ODScoreDef: gofakeit.IntRange(0, math.MaxInt),
|
||||||
|
ODScoreSup: gofakeit.IntRange(0, math.MaxInt),
|
||||||
ODScoreTotal: gofakeit.IntRange(0, math.MaxInt),
|
ODScoreTotal: gofakeit.IntRange(0, math.MaxInt),
|
||||||
Points: gofakeit.IntRange(0, math.MaxInt),
|
Points: gofakeit.IntRange(0, math.MaxInt),
|
||||||
DeletedAt: time.Time{},
|
DeletedAt: time.Time{},
|
||||||
|
@ -41,6 +43,7 @@ func NewPlayerCursor(tb TestingTB, opts ...func(cfg *PlayerCursorConfig)) domain
|
||||||
cfg.ServerKey,
|
cfg.ServerKey,
|
||||||
cfg.ODScoreAtt,
|
cfg.ODScoreAtt,
|
||||||
cfg.ODScoreDef,
|
cfg.ODScoreDef,
|
||||||
|
cfg.ODScoreSup,
|
||||||
cfg.ODScoreTotal,
|
cfg.ODScoreTotal,
|
||||||
cfg.Points,
|
cfg.Points,
|
||||||
cfg.DeletedAt,
|
cfg.DeletedAt,
|
||||||
|
|
|
@ -402,6 +402,8 @@ const (
|
||||||
PlayerSortODScoreAttDESC
|
PlayerSortODScoreAttDESC
|
||||||
PlayerSortODScoreDefASC
|
PlayerSortODScoreDefASC
|
||||||
PlayerSortODScoreDefDESC
|
PlayerSortODScoreDefDESC
|
||||||
|
PlayerSortODScoreSupASC
|
||||||
|
PlayerSortODScoreSupDESC
|
||||||
PlayerSortODScoreTotalASC
|
PlayerSortODScoreTotalASC
|
||||||
PlayerSortODScoreTotalDESC
|
PlayerSortODScoreTotalDESC
|
||||||
PlayerSortPointsASC
|
PlayerSortPointsASC
|
||||||
|
@ -437,6 +439,10 @@ func (s PlayerSort) String() string {
|
||||||
return "odScoreDef:ASC"
|
return "odScoreDef:ASC"
|
||||||
case PlayerSortODScoreDefDESC:
|
case PlayerSortODScoreDefDESC:
|
||||||
return "odScoreDef:DESC"
|
return "odScoreDef:DESC"
|
||||||
|
case PlayerSortODScoreSupASC:
|
||||||
|
return "odScoreSup:ASC"
|
||||||
|
case PlayerSortODScoreSupDESC:
|
||||||
|
return "odScoreSup:DESC"
|
||||||
case PlayerSortODScoreTotalASC:
|
case PlayerSortODScoreTotalASC:
|
||||||
return "odScoreTotal:ASC"
|
return "odScoreTotal:ASC"
|
||||||
case PlayerSortODScoreTotalDESC:
|
case PlayerSortODScoreTotalDESC:
|
||||||
|
@ -460,6 +466,8 @@ func newPlayerSortFromString(s string) (PlayerSort, error) {
|
||||||
PlayerSortODScoreAttDESC,
|
PlayerSortODScoreAttDESC,
|
||||||
PlayerSortODScoreDefASC,
|
PlayerSortODScoreDefASC,
|
||||||
PlayerSortODScoreDefDESC,
|
PlayerSortODScoreDefDESC,
|
||||||
|
PlayerSortODScoreSupASC,
|
||||||
|
PlayerSortODScoreSupDESC,
|
||||||
PlayerSortODScoreTotalASC,
|
PlayerSortODScoreTotalASC,
|
||||||
PlayerSortODScoreTotalDESC,
|
PlayerSortODScoreTotalDESC,
|
||||||
PlayerSortPointsASC,
|
PlayerSortPointsASC,
|
||||||
|
@ -484,6 +492,7 @@ type PlayerCursor struct {
|
||||||
serverKey string
|
serverKey string
|
||||||
odScoreAtt int
|
odScoreAtt int
|
||||||
odScoreDef int
|
odScoreDef int
|
||||||
|
odScoreSup int
|
||||||
odScoreTotal int
|
odScoreTotal int
|
||||||
points int
|
points int
|
||||||
deletedAt time.Time
|
deletedAt time.Time
|
||||||
|
@ -496,6 +505,7 @@ func NewPlayerCursor(
|
||||||
serverKey string,
|
serverKey string,
|
||||||
odScoreAtt int,
|
odScoreAtt int,
|
||||||
odScoreDef int,
|
odScoreDef int,
|
||||||
|
odScoreSup int,
|
||||||
odScoreTotal int,
|
odScoreTotal int,
|
||||||
points int,
|
points int,
|
||||||
deletedAt time.Time,
|
deletedAt time.Time,
|
||||||
|
@ -532,6 +542,14 @@ func NewPlayerCursor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateIntInRange(odScoreSup, 0, math.MaxInt); err != nil {
|
||||||
|
return PlayerCursor{}, ValidationError{
|
||||||
|
Model: playerCursorModelName,
|
||||||
|
Field: "odScoreSup",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := validateIntInRange(odScoreTotal, 0, math.MaxInt); err != nil {
|
if err := validateIntInRange(odScoreTotal, 0, math.MaxInt); err != nil {
|
||||||
return PlayerCursor{}, ValidationError{
|
return PlayerCursor{}, ValidationError{
|
||||||
Model: playerCursorModelName,
|
Model: playerCursorModelName,
|
||||||
|
@ -553,6 +571,7 @@ func NewPlayerCursor(
|
||||||
serverKey: serverKey,
|
serverKey: serverKey,
|
||||||
odScoreAtt: odScoreAtt,
|
odScoreAtt: odScoreAtt,
|
||||||
odScoreDef: odScoreDef,
|
odScoreDef: odScoreDef,
|
||||||
|
odScoreSup: odScoreSup,
|
||||||
odScoreTotal: odScoreTotal,
|
odScoreTotal: odScoreTotal,
|
||||||
points: points,
|
points: points,
|
||||||
deletedAt: deletedAt,
|
deletedAt: deletedAt,
|
||||||
|
@ -586,6 +605,11 @@ func decodePlayerCursor(encoded string) (PlayerCursor, error) {
|
||||||
return PlayerCursor{}, ErrInvalidCursor
|
return PlayerCursor{}, ErrInvalidCursor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
odScoreSup, err := m.int("odScoreSup")
|
||||||
|
if err != nil {
|
||||||
|
return PlayerCursor{}, ErrInvalidCursor
|
||||||
|
}
|
||||||
|
|
||||||
odScoreTotal, err := m.int("odScoreTotal")
|
odScoreTotal, err := m.int("odScoreTotal")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return PlayerCursor{}, ErrInvalidCursor
|
return PlayerCursor{}, ErrInvalidCursor
|
||||||
|
@ -606,6 +630,7 @@ func decodePlayerCursor(encoded string) (PlayerCursor, error) {
|
||||||
serverKey,
|
serverKey,
|
||||||
odScoreAtt,
|
odScoreAtt,
|
||||||
odScoreDef,
|
odScoreDef,
|
||||||
|
odScoreSup,
|
||||||
odScoreTotal,
|
odScoreTotal,
|
||||||
points,
|
points,
|
||||||
deletedAt,
|
deletedAt,
|
||||||
|
@ -633,6 +658,10 @@ func (pc PlayerCursor) ODScoreDef() int {
|
||||||
return pc.odScoreDef
|
return pc.odScoreDef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pc PlayerCursor) ODScoreSup() int {
|
||||||
|
return pc.odScoreSup
|
||||||
|
}
|
||||||
|
|
||||||
func (pc PlayerCursor) ODScoreTotal() int {
|
func (pc PlayerCursor) ODScoreTotal() int {
|
||||||
return pc.odScoreTotal
|
return pc.odScoreTotal
|
||||||
}
|
}
|
||||||
|
@ -659,6 +688,7 @@ func (pc PlayerCursor) Encode() string {
|
||||||
{"serverKey", pc.serverKey},
|
{"serverKey", pc.serverKey},
|
||||||
{"odScoreAtt", pc.odScoreAtt},
|
{"odScoreAtt", pc.odScoreAtt},
|
||||||
{"odScoreDef", pc.odScoreDef},
|
{"odScoreDef", pc.odScoreDef},
|
||||||
|
{"odScoreSup", pc.odScoreSup},
|
||||||
{"odScoreTotal", pc.odScoreTotal},
|
{"odScoreTotal", pc.odScoreTotal},
|
||||||
{"points", pc.points},
|
{"points", pc.points},
|
||||||
{"deletedAt", pc.deletedAt},
|
{"deletedAt", pc.deletedAt},
|
||||||
|
@ -888,6 +918,7 @@ func NewListPlayersResult(players Players, next Player) (ListPlayersResult, erro
|
||||||
players[0].ServerKey(),
|
players[0].ServerKey(),
|
||||||
od.ScoreAtt(),
|
od.ScoreAtt(),
|
||||||
od.ScoreDef(),
|
od.ScoreDef(),
|
||||||
|
od.ScoreSup(),
|
||||||
od.ScoreTotal(),
|
od.ScoreTotal(),
|
||||||
players[0].Points(),
|
players[0].Points(),
|
||||||
players[0].DeletedAt(),
|
players[0].DeletedAt(),
|
||||||
|
@ -908,6 +939,7 @@ func NewListPlayersResult(players Players, next Player) (ListPlayersResult, erro
|
||||||
next.ServerKey(),
|
next.ServerKey(),
|
||||||
od.ScoreAtt(),
|
od.ScoreAtt(),
|
||||||
od.ScoreDef(),
|
od.ScoreDef(),
|
||||||
|
od.ScoreSup(),
|
||||||
od.ScoreTotal(),
|
od.ScoreTotal(),
|
||||||
next.Points(),
|
next.Points(),
|
||||||
next.DeletedAt(),
|
next.DeletedAt(),
|
||||||
|
@ -961,6 +993,7 @@ func NewListPlayersWithRelationsResult(
|
||||||
player.ServerKey(),
|
player.ServerKey(),
|
||||||
od.ScoreAtt(),
|
od.ScoreAtt(),
|
||||||
od.ScoreDef(),
|
od.ScoreDef(),
|
||||||
|
od.ScoreSup(),
|
||||||
od.ScoreTotal(),
|
od.ScoreTotal(),
|
||||||
player.Points(),
|
player.Points(),
|
||||||
player.DeletedAt(),
|
player.DeletedAt(),
|
||||||
|
@ -983,6 +1016,7 @@ func NewListPlayersWithRelationsResult(
|
||||||
player.ServerKey(),
|
player.ServerKey(),
|
||||||
od.ScoreAtt(),
|
od.ScoreAtt(),
|
||||||
od.ScoreDef(),
|
od.ScoreDef(),
|
||||||
|
od.ScoreSup(),
|
||||||
od.ScoreTotal(),
|
od.ScoreTotal(),
|
||||||
player.Points(),
|
player.Points(),
|
||||||
player.DeletedAt(),
|
player.DeletedAt(),
|
||||||
|
|
|
@ -331,6 +331,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey string
|
serverKey string
|
||||||
odScoreAtt int
|
odScoreAtt int
|
||||||
odScoreDef int
|
odScoreDef int
|
||||||
|
odScoreSup int
|
||||||
odScoreTotal int
|
odScoreTotal int
|
||||||
points int
|
points int
|
||||||
deletedAt time.Time
|
deletedAt time.Time
|
||||||
|
@ -350,6 +351,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
odScoreDef: validPlayerCursor.ODScoreDef(),
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
points: validPlayerCursor.Points(),
|
points: validPlayerCursor.Points(),
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -363,6 +365,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
odScoreDef: validPlayerCursor.ODScoreDef(),
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
points: validPlayerCursor.Points(),
|
points: validPlayerCursor.Points(),
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -383,6 +386,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: -1,
|
odScoreAtt: -1,
|
||||||
odScoreDef: validPlayerCursor.ODScoreDef(),
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
points: validPlayerCursor.Points(),
|
points: validPlayerCursor.Points(),
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -403,6 +407,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
odScoreDef: -1,
|
odScoreDef: -1,
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
points: validPlayerCursor.Points(),
|
points: validPlayerCursor.Points(),
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -416,6 +421,27 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "ERR: odScoreSup < 0",
|
||||||
|
args: args{
|
||||||
|
id: validPlayerCursor.ID(),
|
||||||
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: -1,
|
||||||
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
|
points: validPlayerCursor.Points(),
|
||||||
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
},
|
||||||
|
expectedErr: domain.ValidationError{
|
||||||
|
Model: "PlayerCursor",
|
||||||
|
Field: "odScoreSup",
|
||||||
|
Err: domain.MinGreaterEqualError{
|
||||||
|
Min: 0,
|
||||||
|
Current: -1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "ERR: odScoreTotal < 0",
|
name: "ERR: odScoreTotal < 0",
|
||||||
args: args{
|
args: args{
|
||||||
|
@ -423,6 +449,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
odScoreDef: validPlayerCursor.ODScoreDef(),
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: -1,
|
odScoreTotal: -1,
|
||||||
points: validPlayerCursor.Points(),
|
points: validPlayerCursor.Points(),
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -443,6 +470,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
serverKey: validPlayerCursor.ServerKey(),
|
serverKey: validPlayerCursor.ServerKey(),
|
||||||
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
odScoreAtt: validPlayerCursor.ODScoreAtt(),
|
||||||
odScoreDef: validPlayerCursor.ODScoreDef(),
|
odScoreDef: validPlayerCursor.ODScoreDef(),
|
||||||
|
odScoreSup: validPlayerCursor.ODScoreSup(),
|
||||||
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
odScoreTotal: validPlayerCursor.ODScoreTotal(),
|
||||||
points: -1,
|
points: -1,
|
||||||
deletedAt: validPlayerCursor.DeletedAt(),
|
deletedAt: validPlayerCursor.DeletedAt(),
|
||||||
|
@ -487,6 +515,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
tt.args.serverKey,
|
tt.args.serverKey,
|
||||||
tt.args.odScoreAtt,
|
tt.args.odScoreAtt,
|
||||||
tt.args.odScoreDef,
|
tt.args.odScoreDef,
|
||||||
|
tt.args.odScoreSup,
|
||||||
tt.args.odScoreTotal,
|
tt.args.odScoreTotal,
|
||||||
tt.args.points,
|
tt.args.points,
|
||||||
tt.args.deletedAt,
|
tt.args.deletedAt,
|
||||||
|
@ -499,6 +528,7 @@ func TestNewPlayerCursor(t *testing.T) {
|
||||||
assert.Equal(t, tt.args.serverKey, tc.ServerKey())
|
assert.Equal(t, tt.args.serverKey, tc.ServerKey())
|
||||||
assert.Equal(t, tt.args.odScoreAtt, tc.ODScoreAtt())
|
assert.Equal(t, tt.args.odScoreAtt, tc.ODScoreAtt())
|
||||||
assert.Equal(t, tt.args.odScoreDef, tc.ODScoreDef())
|
assert.Equal(t, tt.args.odScoreDef, tc.ODScoreDef())
|
||||||
|
assert.Equal(t, tt.args.odScoreSup, tc.ODScoreSup())
|
||||||
assert.Equal(t, tt.args.odScoreTotal, tc.ODScoreTotal())
|
assert.Equal(t, tt.args.odScoreTotal, tc.ODScoreTotal())
|
||||||
assert.Equal(t, tt.args.points, tc.Points())
|
assert.Equal(t, tt.args.points, tc.Points())
|
||||||
assert.Equal(t, tt.args.deletedAt, tc.DeletedAt())
|
assert.Equal(t, tt.args.deletedAt, tc.DeletedAt())
|
||||||
|
@ -879,27 +909,31 @@ func TestListPlayersParams_PrependSortString(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "OK: [points:ASC, deletedAt:ASC]",
|
name: "OK: [odScoreSup:ASC, points:ASC, deletedAt:ASC]",
|
||||||
args: args{
|
args: args{
|
||||||
sort: []string{
|
sort: []string{
|
||||||
|
"odScoreSup:ASC",
|
||||||
"points:ASC",
|
"points:ASC",
|
||||||
"deletedAt:ASC",
|
"deletedAt:ASC",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedSort: []domain.PlayerSort{
|
expectedSort: []domain.PlayerSort{
|
||||||
|
domain.PlayerSortODScoreSupASC,
|
||||||
domain.PlayerSortPointsASC,
|
domain.PlayerSortPointsASC,
|
||||||
domain.PlayerSortDeletedAtASC,
|
domain.PlayerSortDeletedAtASC,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "OK: [points:DESC, deletedAt:DESC]",
|
name: "OK: [odScoreSup:DESC, points:DESC, deletedAt:DESC]",
|
||||||
args: args{
|
args: args{
|
||||||
sort: []string{
|
sort: []string{
|
||||||
|
"odScoreSup:DESC",
|
||||||
"points:DESC",
|
"points:DESC",
|
||||||
"deletedAt:DESC",
|
"deletedAt:DESC",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedSort: []domain.PlayerSort{
|
expectedSort: []domain.PlayerSort{
|
||||||
|
domain.PlayerSortODScoreSupDESC,
|
||||||
domain.PlayerSortPointsDESC,
|
domain.PlayerSortPointsDESC,
|
||||||
domain.PlayerSortDeletedAtDESC,
|
domain.PlayerSortDeletedAtDESC,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue