submissions: fix list requests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Quaternions 2024-12-17 21:03:39 -08:00
parent b238e4c21d
commit e905d96917
2 changed files with 21 additions and 7 deletions

View File

@ -54,11 +54,18 @@ func (svc *Service) CreateScriptPolicy(ctx context.Context, req *api.ScriptPolic
// GET /script-policy
func (svc *Service) ListScriptPolicy(ctx context.Context, request *api.ListScriptPolicyReq) ([]api.ScriptPolicy, error) {
filter := datastore.Optional()
//fmt.Println(request)
if request.Filter.IsSet() {
filter.AddNotNil("from_script_hash", request.Filter.Value.FromScriptHash)
filter.AddNotNil("to_script_id", request.Filter.Value.ToScriptID)
filter.AddNotNil("policy", request.Filter.Value.Policy)
f := request.Filter.Value
if f.FromScriptHash.IsSet(){
filter.AddNotNil("from_script_hash", f.FromScriptHash.Value)
}
if f.ToScriptID.IsSet(){
filter.AddNotNil("to_script_id", f.ToScriptID.Value)
}
if f.Policy.IsSet(){
filter.AddNotNil("policy", f.Policy.Value)
}
}
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{

View File

@ -71,9 +71,16 @@ func (svc *Service) ListSubmissions(ctx context.Context, request *api.ListSubmis
filter := datastore.Optional()
//fmt.Println(request)
if request.Filter.IsSet() {
filter.AddNotNil("display_name", request.Filter.Value.DisplayName)
filter.AddNotNil("creator", request.Filter.Value.Creator)
filter.AddNotNil("game_id", request.Filter.Value.GameID)
f := request.Filter.Value
if f.DisplayName.IsSet(){
filter.Add("display_name", f.DisplayName.Value)
}
if f.Creator.IsSet(){
filter.Add("creator", f.Creator.Value)
}
if f.GameID.IsSet(){
filter.Add("game_id", f.GameID.Value)
}
}
items, err := svc.DB.Submissions().List(ctx, filter, model.Page{