limit the number of orders someone can add to a query (3)
This commit is contained in:
parent
6a44193f31
commit
7f59bcf2cd
|
@ -2,4 +2,5 @@ package dailyplayerstats
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 1000
|
FetchLimit = 1000
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg dailyplayerstats.FetchConfi
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > dailyplayerstats.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > dailyplayerstats.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = dailyplayerstats.FetchLimit
|
cfg.Limit = dailyplayerstats.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > dailyplayerstats.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:dailyplayerstats.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package dailytribestats
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 1000
|
FetchLimit = 1000
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg dailytribestats.FetchConfig
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > dailytribestats.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > dailytribestats.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = dailytribestats.FetchLimit
|
cfg.Limit = dailytribestats.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > dailytribestats.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:dailytribestats.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package ennoblement
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 200
|
FetchLimit = 200
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg ennoblement.FetchConfig) ([
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > ennoblement.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > ennoblement.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = ennoblement.FetchLimit
|
cfg.Limit = ennoblement.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > ennoblement.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:ennoblement.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package player
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 200
|
FetchLimit = 200
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,6 +25,9 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg player.FetchConfig) ([]*twm
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > player.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > player.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = player.FetchLimit
|
cfg.Limit = player.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > player.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:player.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,5 +60,8 @@ func (ucase *usecase) SearchPlayer(ctx context.Context, cfg player.SearchPlayerC
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > player.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > player.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = player.FetchLimit
|
cfg.Limit = player.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > player.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:player.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.SearchPlayer(ctx, cfg)
|
return ucase.repo.SearchPlayer(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package playerhistory
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 100
|
FetchLimit = 100
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg playerhistory.FetchConfig)
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > playerhistory.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > playerhistory.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = playerhistory.FetchLimit
|
cfg.Limit = playerhistory.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > playerhistory.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:playerhistory.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package server
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 100
|
FetchLimit = 100
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,6 +24,9 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg server.FetchConfig) ([]*twm
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > server.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > server.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = server.FetchLimit
|
cfg.Limit = server.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > server.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:server.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package servermap
|
||||||
|
|
||||||
|
const (
|
||||||
|
MaxMarkers = 100
|
||||||
|
)
|
|
@ -210,7 +210,11 @@ func toMarkers(params []string) (map[string][]int, []int, error) {
|
||||||
idsByColor := make(map[string][]int)
|
idsByColor := make(map[string][]int)
|
||||||
var ids []int
|
var ids []int
|
||||||
cache := make(map[int]bool)
|
cache := make(map[int]bool)
|
||||||
|
count := 0
|
||||||
for _, param := range params {
|
for _, param := range params {
|
||||||
|
if count >= servermap.MaxMarkers {
|
||||||
|
break
|
||||||
|
}
|
||||||
//id,#color
|
//id,#color
|
||||||
id, color, err := toMarker(param)
|
id, color, err := toMarker(param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -222,6 +226,7 @@ func toMarkers(params []string) (map[string][]int, []int, error) {
|
||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
cache[id] = true
|
cache[id] = true
|
||||||
idsByColor[color] = append(idsByColor[color], id)
|
idsByColor[color] = append(idsByColor[color], id)
|
||||||
|
count++
|
||||||
}
|
}
|
||||||
return idsByColor, ids, nil
|
return idsByColor, ids, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package serverstats
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 60
|
FetchLimit = 60
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg serverstats.FetchConfig) ([
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > serverstats.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > serverstats.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = serverstats.FetchLimit
|
cfg.Limit = serverstats.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > serverstats.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:serverstats.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package tribe
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 200
|
FetchLimit = 200
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,6 +25,9 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg tribe.FetchConfig) ([]*twmo
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribe.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribe.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = tribe.FetchLimit
|
cfg.Limit = tribe.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > tribe.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:tribe.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,5 +60,8 @@ func (ucase *usecase) SearchTribe(ctx context.Context, cfg tribe.SearchTribeConf
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribe.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribe.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = tribe.FetchLimit
|
cfg.Limit = tribe.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > tribe.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:tribe.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.SearchTribe(ctx, cfg)
|
return ucase.repo.SearchTribe(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package tribechange
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 100
|
FetchLimit = 100
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg tribechange.FetchConfig) ([
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribechange.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribechange.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = tribechange.FetchLimit
|
cfg.Limit = tribechange.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > tribechange.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:tribechange.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package tribehistory
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 100
|
FetchLimit = 100
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,5 +23,8 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg tribehistory.FetchConfig) (
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribehistory.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > tribehistory.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = tribehistory.FetchLimit
|
cfg.Limit = tribehistory.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > tribehistory.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:tribehistory.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ package version
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 30
|
FetchLimit = 30
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,6 +26,9 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg version.FetchConfig) ([]*tw
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > version.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > version.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = version.FetchLimit
|
cfg.Limit = version.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > version.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:version.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,5 @@ package village
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FetchLimit = 1000
|
FetchLimit = 1000
|
||||||
|
MaxOrders = 3
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,6 +24,9 @@ func (ucase *usecase) Fetch(ctx context.Context, cfg village.FetchConfig) ([]*tw
|
||||||
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > village.FetchLimit || cfg.Limit <= 0) {
|
if !middleware.CanExceedLimit(ctx) && (cfg.Limit > village.FetchLimit || cfg.Limit <= 0) {
|
||||||
cfg.Limit = village.FetchLimit
|
cfg.Limit = village.FetchLimit
|
||||||
}
|
}
|
||||||
|
if len(cfg.Sort) > village.MaxOrders {
|
||||||
|
cfg.Sort = cfg.Sort[0:village.MaxOrders]
|
||||||
|
}
|
||||||
return ucase.repo.Fetch(ctx, cfg)
|
return ucase.repo.Fetch(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue