Finish resource search wf handlers
* Remove page cursor from response, * correctly return totals.
This commit is contained in:
@@ -236,9 +236,8 @@ type (
|
||||
}
|
||||
|
||||
recordsSearchResults struct {
|
||||
Records []*types.Record
|
||||
Total uint64
|
||||
PageCursor string
|
||||
Records []*types.Record
|
||||
Total uint64
|
||||
}
|
||||
)
|
||||
|
||||
@@ -328,11 +327,6 @@ func (h recordsHandler) Search() *atypes.Function {
|
||||
Description: "Total items that satisfy given conditions.\n\nNeeds to be explicitly requested with incTotal argument",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "pageCursor",
|
||||
Types: []string{"String"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
@@ -421,19 +415,6 @@ func (h recordsHandler) Search() *atypes.Function {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// converting results.PageCursor (string) to String
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("String").Cast(results.PageCursor); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "pageCursor", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ func (h recordsHandler) search(ctx context.Context, args *recordsSearchArgs) (re
|
||||
f.Limit = uint(args.Limit)
|
||||
}
|
||||
|
||||
results.Records, _, err = h.rec.Find(ctx, f)
|
||||
var auxf types.RecordFilter
|
||||
results.Records, auxf, err = h.rec.Find(ctx, f)
|
||||
results.Total = uint64(auxf.Total)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ functions:
|
||||
<<: *rvRecord
|
||||
isArray: true
|
||||
total: *rvTotal
|
||||
pageCursor: *rvPageCursor
|
||||
|
||||
first:
|
||||
meta:
|
||||
|
||||
@@ -177,9 +177,8 @@ type (
|
||||
}
|
||||
|
||||
rolesSearchResults struct {
|
||||
Roles []*types.Role
|
||||
Total uint64
|
||||
PageCursor string
|
||||
Roles []*types.Role
|
||||
Total uint64
|
||||
}
|
||||
)
|
||||
|
||||
@@ -261,11 +260,6 @@ func (h rolesHandler) Search() *atypes.Function {
|
||||
Name: "total",
|
||||
Types: []string{"UnsignedInteger"},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "pageCursor",
|
||||
Types: []string{"String"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
@@ -330,19 +324,6 @@ func (h rolesHandler) Search() *atypes.Function {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// converting results.PageCursor (string) to String
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("String").Cast(results.PageCursor); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "pageCursor", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package automation
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
. "github.com/cortezaproject/corteza-server/pkg/expr"
|
||||
"github.com/cortezaproject/corteza-server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza-server/pkg/wfexec"
|
||||
@@ -91,7 +92,9 @@ func (h rolesHandler) search(ctx context.Context, args *rolesSearchArgs) (result
|
||||
f.Limit = uint(args.Limit)
|
||||
}
|
||||
|
||||
results.Roles, _, err = h.rSvc.Find(ctx, f)
|
||||
var auxf types.RoleFilter
|
||||
results.Roles, auxf, err = h.rSvc.Find(ctx, f)
|
||||
results.Total = uint64(auxf.Total)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,6 @@ functions:
|
||||
<<: *rvRole
|
||||
isArray: true
|
||||
total: *rvTotal
|
||||
pageCursor: *rvPageCursor
|
||||
|
||||
each:
|
||||
kind: iterator
|
||||
|
||||
@@ -10,6 +10,7 @@ package automation
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
atypes "github.com/cortezaproject/corteza-server/automation/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/expr"
|
||||
"github.com/cortezaproject/corteza-server/pkg/wfexec"
|
||||
@@ -170,9 +171,8 @@ type (
|
||||
}
|
||||
|
||||
templatesSearchResults struct {
|
||||
Templates []*types.Template
|
||||
Total uint64
|
||||
PageCursor string
|
||||
Templates []*types.Template
|
||||
Total uint64
|
||||
}
|
||||
)
|
||||
|
||||
@@ -246,11 +246,6 @@ func (h templatesHandler) Search() *atypes.Function {
|
||||
Name: "total",
|
||||
Types: []string{"UnsignedInteger"},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "pageCursor",
|
||||
Types: []string{"String"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
@@ -313,19 +308,6 @@ func (h templatesHandler) Search() *atypes.Function {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// converting results.PageCursor (string) to String
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("String").Cast(results.PageCursor); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "pageCursor", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
||||
@@ -83,7 +83,6 @@ functions:
|
||||
<<: *rvTemplate
|
||||
isArray: true
|
||||
total: *rvTotal
|
||||
pageCursor: *rvPageCursor
|
||||
|
||||
each:
|
||||
kind: iterator
|
||||
|
||||
@@ -177,9 +177,8 @@ type (
|
||||
}
|
||||
|
||||
usersSearchResults struct {
|
||||
Users []*types.User
|
||||
Total uint64
|
||||
PageCursor string
|
||||
Users []*types.User
|
||||
Total uint64
|
||||
}
|
||||
)
|
||||
|
||||
@@ -257,11 +256,6 @@ func (h usersHandler) Search() *atypes.Function {
|
||||
Name: "total",
|
||||
Types: []string{"UnsignedInteger"},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "pageCursor",
|
||||
Types: []string{"String"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
@@ -325,19 +319,6 @@ func (h usersHandler) Search() *atypes.Function {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// converting results.PageCursor (string) to String
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("String").Cast(results.PageCursor); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "pageCursor", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package automation
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
. "github.com/cortezaproject/corteza-server/pkg/expr"
|
||||
"github.com/cortezaproject/corteza-server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza-server/pkg/wfexec"
|
||||
@@ -91,7 +92,9 @@ func (h usersHandler) search(ctx context.Context, args *usersSearchArgs) (result
|
||||
f.Limit = uint(args.Limit)
|
||||
}
|
||||
|
||||
results.Users, _, err = h.uSvc.Find(ctx, f)
|
||||
var auxf types.UserFilter
|
||||
results.Users, auxf, err = h.uSvc.Find(ctx, f)
|
||||
results.Total = uint64(auxf.Total)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ functions:
|
||||
<<: *rvUser
|
||||
isArray: true
|
||||
total: *rvTotal
|
||||
pageCursor: *rvPageCursor
|
||||
|
||||
each:
|
||||
kind: iterator
|
||||
|
||||
Reference in New Issue
Block a user