diff --git a/Makefile b/Makefile index 5224ce3..3c23bb2 100644 --- a/Makefile +++ b/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)" diff --git a/api/openapi3.yml b/api/openapi3.yml index 3fff94a..c165743 100644 --- a/api/openapi3.yml +++ b/api/openapi3.yml @@ -1328,6 +1328,8 @@ components: schema: type: integer minimum: 1 + default: 500 + maximum: 500 required: false ServerOpenQueryParam: name: open diff --git a/internal/adapter/repository_bun_ennoblement.go b/internal/adapter/repository_bun_ennoblement.go index 8bb2a96..7e65df6 100644 --- a/internal/adapter/repository_bun_ennoblement.go +++ b/internal/adapter/repository_bun_ennoblement.go @@ -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). diff --git a/internal/adapter/repository_player_test.go b/internal/adapter/repository_player_test.go index cb7218e..bc301a7 100644 --- a/internal/adapter/repository_player_test.go +++ b/internal/adapter/repository_player_test.go @@ -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() diff --git a/internal/domain/ennoblement.go b/internal/domain/ennoblement.go index 1f8b6b1..cd57a38 100644 --- a/internal/domain/ennoblement.go +++ b/internal/domain/ennoblement.go @@ -360,7 +360,7 @@ type ListEnnoblementsParams struct { } const ( - EnnoblementListMaxLimit = 200 + EnnoblementListMaxLimit = 500 listEnnoblementsParamsModelName = "ListEnnoblementsParams" ) diff --git a/internal/domain/player.go b/internal/domain/player.go index 30abdee..ad60dc5 100644 --- a/internal/domain/player.go +++ b/internal/domain/player.go @@ -830,7 +830,7 @@ type ListPlayersParams struct { } const ( - PlayerListMaxLimit = 200 + PlayerListMaxLimit = 500 listPlayersParamsModelName = "ListPlayersParams" ) diff --git a/internal/domain/player_snapshot.go b/internal/domain/player_snapshot.go index fca947a..fcecbcf 100644 --- a/internal/domain/player_snapshot.go +++ b/internal/domain/player_snapshot.go @@ -228,7 +228,7 @@ func (s PlayerSnapshotSort) String() string { } } -const PlayerSnapshotListMaxLimit = 200 +const PlayerSnapshotListMaxLimit = 500 type ListPlayerSnapshotsParams struct { serverKeys []string diff --git a/internal/domain/tribe.go b/internal/domain/tribe.go index 424ed60..7a9dae6 100644 --- a/internal/domain/tribe.go +++ b/internal/domain/tribe.go @@ -749,7 +749,7 @@ type ListTribesParams struct { } const ( - TribeListMaxLimit = 200 + TribeListMaxLimit = 500 listTribesParamsModelName = "ListTribesParams" ) diff --git a/internal/domain/tribe_change.go b/internal/domain/tribe_change.go index e156438..520d513 100644 --- a/internal/domain/tribe_change.go +++ b/internal/domain/tribe_change.go @@ -249,7 +249,7 @@ type ListTribeChangesParams struct { } const ( - TribeChangeListMaxLimit = 200 + TribeChangeListMaxLimit = 500 listTribeChangesParamsModelName = "ListTribeChangesParams" ) diff --git a/internal/domain/tribe_snapshot.go b/internal/domain/tribe_snapshot.go index 0857534..1afedcf 100644 --- a/internal/domain/tribe_snapshot.go +++ b/internal/domain/tribe_snapshot.go @@ -262,7 +262,7 @@ type ListTribeSnapshotsParams struct { } const ( - TribeSnapshotListMaxLimit = 200 + TribeSnapshotListMaxLimit = 500 listTribeSnapshotsParamsModelName = "ListTribeSnapshotsParams" ) diff --git a/internal/domain/version.go b/internal/domain/version.go index 98fead7..14ca043 100644 --- a/internal/domain/version.go +++ b/internal/domain/version.go @@ -189,7 +189,7 @@ type ListVersionsParams struct { } const ( - VersionListMaxLimit = 200 + VersionListMaxLimit = 500 listVersionsParamsModelName = "ListVersionsParams" ) diff --git a/internal/port/handler_http_api_ennoblement.go b/internal/port/handler_http_api_ennoblement.go index f2c12dc..150754c 100644 --- a/internal/port/handler_http_api_ennoblement.go +++ b/internal/port/handler_http_api_ennoblement.go @@ -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 } diff --git a/internal/port/handler_http_api_ennoblement_test.go b/internal/port/handler_http_api_ennoblement_test.go index 0d6df65..8a47ec0 100644 --- a/internal/port/handler_http_api_ennoblement_test.go +++ b/internal/port/handler_http_api_ennoblement_test.go @@ -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{ diff --git a/internal/port/handler_http_api_player_test.go b/internal/port/handler_http_api_player_test.go index 1ec7cba..b5c4a17 100644 --- a/internal/port/handler_http_api_player_test.go +++ b/internal/port/handler_http_api_player_test.go @@ -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{ diff --git a/internal/port/handler_http_api_server_test.go b/internal/port/handler_http_api_server_test.go index 1185da2..c22e595 100644 --- a/internal/port/handler_http_api_server_test.go +++ b/internal/port/handler_http_api_server_test.go @@ -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{ diff --git a/internal/port/handler_http_api_tribe_test.go b/internal/port/handler_http_api_tribe_test.go index 22940e4..f96d124 100644 --- a/internal/port/handler_http_api_tribe_test.go +++ b/internal/port/handler_http_api_tribe_test.go @@ -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{ diff --git a/internal/port/handler_http_api_version_test.go b/internal/port/handler_http_api_version_test.go index 204d700..3db3c5b 100644 --- a/internal/port/handler_http_api_version_test.go +++ b/internal/port/handler_http_api_version_test.go @@ -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{ diff --git a/internal/port/handler_http_api_village_test.go b/internal/port/handler_http_api_village_test.go index 65732f6..5c0cacd 100644 --- a/internal/port/handler_http_api_village_test.go +++ b/internal/port/handler_http_api_village_test.go @@ -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{