refactor: change max limit to 500 for all models
This commit is contained in:
parent
b2fa484902
commit
fc5f531ce7
6
Makefile
6
Makefile
|
@ -36,12 +36,12 @@ generate: install-oapi-codegen
|
|||
|
||||
.PHONY: create-job-sync-data
|
||||
create-job-sync-data:
|
||||
kubectl create job --from=cronjob/twhelp-job-sync-data-dev "twhelp-job-sync-data-$(shell openssl rand -hex 10)"
|
||||
@kubectl create job --from=cronjob/twhelp-job-sync-data-dev "twhelp-job-sync-data-$(shell openssl rand -hex 10)"
|
||||
|
||||
.PHONY: create-job-sync-ennoblements
|
||||
create-job-sync-ennoblements:
|
||||
kubectl create job --from=cronjob/twhelp-job-sync-ennoblements-dev "twhelp-job-sync-ennoblements-$(shell openssl rand -hex 10)"
|
||||
@kubectl create job --from=cronjob/twhelp-job-sync-ennoblements-dev "twhelp-job-sync-ennoblements-$(shell openssl rand -hex 10)"
|
||||
|
||||
.PHONY: create-job-create-snapshots
|
||||
create-job-create-snapshots:
|
||||
kubectl create job --from=cronjob/twhelp-job-create-snapshots-dev "twhelp-job-create-snapshots-$(shell openssl rand -hex 10)"
|
||||
@kubectl create job --from=cronjob/twhelp-job-create-snapshots-dev "twhelp-job-create-snapshots-$(shell openssl rand -hex 10)"
|
||||
|
|
|
@ -1328,6 +1328,8 @@ components:
|
|||
schema:
|
||||
type: integer
|
||||
minimum: 1
|
||||
default: 500
|
||||
maximum: 500
|
||||
required: false
|
||||
ServerOpenQueryParam:
|
||||
name: open
|
||||
|
|
|
@ -78,6 +78,25 @@ func (repo *EnnoblementBunRepository) ListWithRelations(
|
|||
) (domain.ListEnnoblementsWithRelationsResult, error) {
|
||||
var ennoblements bunmodel.Ennoblements
|
||||
|
||||
fmt.Println(repo.db.NewSelect().
|
||||
Model(&ennoblements).
|
||||
Apply(listEnnoblementsParamsApplier{params: params}.apply).
|
||||
Relation("Village", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||
return q.Column(bunmodel.VillageMetaColumns...)
|
||||
}).
|
||||
Relation("NewOwner", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||
return q.Column(bunmodel.PlayerMetaColumns...)
|
||||
}).
|
||||
Relation("NewTribe", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||
return q.Column(bunmodel.TribeMetaColumns...)
|
||||
}).
|
||||
Relation("OldOwner", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||
return q.Column(bunmodel.PlayerMetaColumns...)
|
||||
}).
|
||||
Relation("OldTribe", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||
return q.Column(bunmodel.TribeMetaColumns...)
|
||||
}).String())
|
||||
|
||||
if err := repo.db.NewSelect().
|
||||
Model(&ennoblements).
|
||||
Apply(listEnnoblementsParamsApplier{params: params}.apply).
|
||||
|
|
|
@ -128,7 +128,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
)
|
||||
}))
|
||||
assert.False(t, res.Self().IsZero())
|
||||
assert.False(t, res.Next().IsZero())
|
||||
assert.True(t, res.Next().IsZero())
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
|
|
|
@ -360,7 +360,7 @@ type ListEnnoblementsParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
EnnoblementListMaxLimit = 200
|
||||
EnnoblementListMaxLimit = 500
|
||||
listEnnoblementsParamsModelName = "ListEnnoblementsParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -830,7 +830,7 @@ type ListPlayersParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
PlayerListMaxLimit = 200
|
||||
PlayerListMaxLimit = 500
|
||||
listPlayersParamsModelName = "ListPlayersParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ func (s PlayerSnapshotSort) String() string {
|
|||
}
|
||||
}
|
||||
|
||||
const PlayerSnapshotListMaxLimit = 200
|
||||
const PlayerSnapshotListMaxLimit = 500
|
||||
|
||||
type ListPlayerSnapshotsParams struct {
|
||||
serverKeys []string
|
||||
|
|
|
@ -749,7 +749,7 @@ type ListTribesParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
TribeListMaxLimit = 200
|
||||
TribeListMaxLimit = 500
|
||||
listTribesParamsModelName = "ListTribesParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ type ListTribeChangesParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
TribeChangeListMaxLimit = 200
|
||||
TribeChangeListMaxLimit = 500
|
||||
listTribeChangesParamsModelName = "ListTribeChangesParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ type ListTribeSnapshotsParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
TribeSnapshotListMaxLimit = 200
|
||||
TribeSnapshotListMaxLimit = 500
|
||||
listTribeSnapshotsParamsModelName = "ListTribeSnapshotsParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ type ListVersionsParams struct {
|
|||
}
|
||||
|
||||
const (
|
||||
VersionListMaxLimit = 200
|
||||
VersionListMaxLimit = 500
|
||||
listVersionsParamsModelName = "ListVersionsParams"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package port
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
|
||||
|
@ -42,6 +43,7 @@ func (h *apiHTTPHandler) ListEnnoblements(
|
|||
|
||||
res, err := h.ennoblementSvc.ListWithRelations(r.Context(), domainParams)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
h.errorRenderer.render(w, r, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -168,11 +168,11 @@ func TestListEnnoblements(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 200",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.EnnoblementListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "201")
|
||||
q.Set("limit", strconv.Itoa(domain.EnnoblementListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -185,7 +185,7 @@ func TestListEnnoblements(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 200,
|
||||
Max: domain.EnnoblementListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
|
@ -321,11 +321,11 @@ func TestListPlayers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 200",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.PlayerListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "201")
|
||||
q.Set("limit", strconv.Itoa(domain.PlayerListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -338,7 +338,7 @@ func TestListPlayers(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 200,
|
||||
Max: domain.PlayerListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
@ -980,11 +980,11 @@ func TestListTribeMembers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 200",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.PlayerListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "201")
|
||||
q.Set("limit", strconv.Itoa(domain.PlayerListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -997,7 +997,7 @@ func TestListTribeMembers(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 200,
|
||||
Max: domain.PlayerListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
|
@ -218,11 +218,11 @@ func TestListServers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 500",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.ServerListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "501")
|
||||
q.Set("limit", strconv.Itoa(domain.ServerListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -235,7 +235,7 @@ func TestListServers(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 500,
|
||||
Max: domain.ServerListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
|
@ -321,11 +321,11 @@ func TestListTribes(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 200",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.TribeListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "201")
|
||||
q.Set("limit", strconv.Itoa(domain.TribeListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -338,7 +338,7 @@ func TestListTribes(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 200,
|
||||
Max: domain.TribeListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
|
@ -166,11 +166,11 @@ func TestListVersions(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 200",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.VersionListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "201")
|
||||
q.Set("limit", strconv.Itoa(domain.VersionListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -183,7 +183,7 @@ func TestListVersions(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 200,
|
||||
Max: domain.VersionListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
|
@ -205,11 +205,11 @@ func TestListVillages(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 500",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.VillageListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "501")
|
||||
q.Set("limit", strconv.Itoa(domain.VillageListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -222,7 +222,7 @@ func TestListVillages(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 500,
|
||||
Max: domain.VillageListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
@ -649,11 +649,11 @@ func TestListPlayerVillages(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 500",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.VillageListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "501")
|
||||
q.Set("limit", strconv.Itoa(domain.VillageListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -666,7 +666,7 @@ func TestListPlayerVillages(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 500,
|
||||
Max: domain.VillageListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
@ -1062,11 +1062,11 @@ func TestListTribeVillages(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "ERR: limit > 500",
|
||||
name: fmt.Sprintf("ERR: limit > %d", domain.VillageListMaxLimit),
|
||||
reqModifier: func(t *testing.T, req *http.Request) {
|
||||
t.Helper()
|
||||
q := req.URL.Query()
|
||||
q.Set("limit", "501")
|
||||
q.Set("limit", strconv.Itoa(domain.VillageListMaxLimit+1))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
},
|
||||
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
|
||||
|
@ -1079,7 +1079,7 @@ func TestListTribeVillages(t *testing.T) {
|
|||
limit, err := strconv.Atoi(req.URL.Query().Get("limit"))
|
||||
require.NoError(t, err)
|
||||
domainErr := domain.MaxLessEqualError{
|
||||
Max: 500,
|
||||
Max: domain.VillageListMaxLimit,
|
||||
Current: limit,
|
||||
}
|
||||
assert.Equal(t, apimodel.ErrorResponse{
|
||||
|
|
Loading…
Reference in New Issue