Add IncTotal param support to all resource List API

- Updates rdbms.go.tpl to extends store search method to include total in response
This commit is contained in:
Vivek Patel
2022-09-21 19:24:43 +05:30
parent 9d46f5c234
commit 7da0940ae1
33 changed files with 836 additions and 6 deletions
+2
View File
@@ -27,6 +27,7 @@ endpoints:
- { name: disabled, type: "uint", title: "Exclude (0, default), include (1) or return only (2) disabled workflows" }
- { name: labels, type: "map[string]string", title: "Labels", parser: "label.ParseStrings" }
- { name: limit, type: "uint", title: "Limit" }
- { name: incTotal, type: "bool", title: "Include total rows counter" }
- { name: pageCursor, type: "string", title: "Page cursor" }
- { name: sort, type: "string", title: "Sort items" }
- name: create
@@ -199,6 +200,7 @@ endpoints:
- { name: eventType, type: "string", title: "Filter event type" }
- { name: resourceType, type: "string", title: "Filter resource type" }
- { name: limit, type: "uint", title: "Limit" }
- { name: incTotal, type: "bool", title: "Include total rows counter" }
- { name: pageCursor, type: "string", title: "Page cursor" }
- { name: sort, type: "string", title: "Sort items" }
- name: read
+17
View File
@@ -76,6 +76,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total rows counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -138,6 +143,7 @@ func (r SessionList) Auditable() map[string]interface{} {
"eventType": r.EventType,
"resourceType": r.ResourceType,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -183,6 +189,11 @@ func (r SessionList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r SessionList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r SessionList) GetPageCursor() string {
return r.PageCursor
@@ -268,6 +279,12 @@ func (r *SessionList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -67,6 +67,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total rows counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -282,6 +287,7 @@ func (r WorkflowList) Auditable() map[string]interface{} {
"disabled": r.Disabled,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -317,6 +323,11 @@ func (r WorkflowList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r WorkflowList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r WorkflowList) GetPageCursor() string {
return r.PageCursor
@@ -380,6 +391,12 @@ func (r *WorkflowList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+2
View File
@@ -67,6 +67,8 @@ func (ctrl Session) List(ctx context.Context, r *request.SessionList) (interface
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -95,6 +95,8 @@ func (ctrl Workflow) List(ctx context.Context, r *request.WorkflowList) (interfa
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
@@ -162,6 +162,26 @@ func (s *Store) Search{{ .expIdentPlural }}(ctx context.Context, {{ template "ex
if err != nil {
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet {{ .goSetType }}
if navSet, _, _, err = s.fetchFullPageOf{{ .expIdentPlural }}(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
{{ else }}
set, _, err = s.Query{{ .expIdentPlural }}(ctx, f)
if err != nil {
+9
View File
@@ -33,6 +33,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: map[string]string
name: labels
title: Labels
@@ -532,6 +535,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
@@ -943,6 +949,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
+2
View File
@@ -73,6 +73,8 @@ func (ctrl Chart) List(ctx context.Context, r *request.ChartList) (interface{},
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -83,6 +83,8 @@ func (ctrl *Module) List(ctx context.Context, r *request.ModuleList) (interface{
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -106,6 +106,8 @@ func (ctrl Namespace) List(ctx context.Context, r *request.NamespaceList) (inter
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+17
View File
@@ -63,6 +63,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -205,6 +210,7 @@ func (r ChartList) Auditable() map[string]interface{} {
"handle": r.Handle,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -235,6 +241,11 @@ func (r ChartList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r ChartList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r ChartList) GetPageCursor() string {
return r.PageCursor
@@ -281,6 +292,12 @@ func (r *ChartList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -64,6 +64,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -253,6 +258,7 @@ func (r ModuleList) Auditable() map[string]interface{} {
"name": r.Name,
"handle": r.Handle,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"labels": r.Labels,
"sort": r.Sort,
@@ -284,6 +290,11 @@ func (r ModuleList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r ModuleList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r ModuleList) GetPageCursor() string {
return r.PageCursor
@@ -330,6 +341,12 @@ func (r *ModuleList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -53,6 +53,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// Labels GET parameter
//
// Labels
@@ -260,6 +265,7 @@ func (r NamespaceList) Auditable() map[string]interface{} {
"query": r.Query,
"slug": r.Slug,
"limit": r.Limit,
"incTotal": r.IncTotal,
"labels": r.Labels,
"pageCursor": r.PageCursor,
"sort": r.Sort,
@@ -281,6 +287,11 @@ func (r NamespaceList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r NamespaceList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r NamespaceList) GetLabels() map[string]string {
return r.Labels
@@ -321,6 +332,12 @@ func (r *NamespaceList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["labels[]"]; ok {
r.Labels, err = label.ParseStrings(val)
if err != nil {
+513
View File
@@ -488,6 +488,25 @@ func (s *Store) SearchApigwFilters(ctx context.Context, f systemType.ApigwFilter
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ApigwFilterSet
if navSet, _, _, err = s.fetchFullPageOfApigwFilters(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -1024,6 +1043,25 @@ func (s *Store) SearchApigwRoutes(ctx context.Context, f systemType.ApigwRouteFi
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ApigwRouteSet
if navSet, _, _, err = s.fetchFullPageOfApigwRoutes(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -1564,6 +1602,25 @@ func (s *Store) SearchApplications(ctx context.Context, f systemType.Application
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ApplicationSet
if navSet, _, _, err = s.fetchFullPageOfApplications(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -2059,6 +2116,25 @@ func (s *Store) SearchAttachments(ctx context.Context, f systemType.AttachmentFi
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.AttachmentSet
if navSet, _, _, err = s.fetchFullPageOfAttachments(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -2549,6 +2625,25 @@ func (s *Store) SearchAuthClients(ctx context.Context, f systemType.AuthClientFi
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.AuthClientSet
if navSet, _, _, err = s.fetchFullPageOfAuthClients(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -4109,6 +4204,25 @@ func (s *Store) SearchAutomationSessions(ctx context.Context, f automationType.S
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet automationType.SessionSet
if navSet, _, _, err = s.fetchFullPageOfAutomationSessions(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -4614,6 +4728,25 @@ func (s *Store) SearchAutomationTriggers(ctx context.Context, f automationType.T
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet automationType.TriggerSet
if navSet, _, _, err = s.fetchFullPageOfAutomationTriggers(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -5115,6 +5248,25 @@ func (s *Store) SearchAutomationWorkflows(ctx context.Context, f automationType.
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet automationType.WorkflowSet
if navSet, _, _, err = s.fetchFullPageOfAutomationWorkflows(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -5678,6 +5830,25 @@ func (s *Store) SearchComposeAttachments(ctx context.Context, f composeType.Atta
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet composeType.AttachmentSet
if navSet, _, _, err = s.fetchFullPageOfComposeAttachments(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -6172,6 +6343,25 @@ func (s *Store) SearchComposeCharts(ctx context.Context, f composeType.ChartFilt
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet composeType.ChartSet
if navSet, _, _, err = s.fetchFullPageOfComposeCharts(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -6707,6 +6897,25 @@ func (s *Store) SearchComposeModules(ctx context.Context, f composeType.ModuleFi
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet composeType.ModuleSet
if navSet, _, _, err = s.fetchFullPageOfComposeModules(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -7692,6 +7901,25 @@ func (s *Store) SearchComposeNamespaces(ctx context.Context, f composeType.Names
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet composeType.NamespaceSet
if navSet, _, _, err = s.fetchFullPageOfComposeNamespaces(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -8252,6 +8480,25 @@ func (s *Store) SearchComposePages(ctx context.Context, f composeType.PageFilter
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet composeType.PageSet
if navSet, _, _, err = s.fetchFullPageOfComposePages(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -9828,6 +10075,25 @@ func (s *Store) SearchDataPrivacyRequests(ctx context.Context, f systemType.Data
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.DataPrivacyRequestSet
if navSet, _, _, err = s.fetchFullPageOfDataPrivacyRequests(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -10328,6 +10594,25 @@ func (s *Store) SearchDataPrivacyRequestComments(ctx context.Context, f systemTy
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.DataPrivacyRequestCommentSet
if navSet, _, _, err = s.fetchFullPageOfDataPrivacyRequestComments(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -10772,6 +11057,25 @@ func (s *Store) SearchFederationExposedModules(ctx context.Context, f federation
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet federationType.ExposedModuleSet
if navSet, _, _, err = s.fetchFullPageOfFederationExposedModules(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -11269,6 +11573,25 @@ func (s *Store) SearchFederationModuleMappings(ctx context.Context, f federation
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet federationType.ModuleMappingSet
if navSet, _, _, err = s.fetchFullPageOfFederationModuleMappings(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -12202,6 +12525,25 @@ func (s *Store) SearchFederationNodeSyncs(ctx context.Context, f federationType.
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet federationType.NodeSyncSet
if navSet, _, _, err = s.fetchFullPageOfFederationNodeSyncs(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -12738,6 +13080,25 @@ func (s *Store) SearchFederationSharedModules(ctx context.Context, f federationT
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet federationType.SharedModuleSet
if navSet, _, _, err = s.fetchFullPageOfFederationSharedModules(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -13848,6 +14209,25 @@ func (s *Store) SearchQueues(ctx context.Context, f systemType.QueueFilter) (set
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.QueueSet
if navSet, _, _, err = s.fetchFullPageOfQueues(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -14378,6 +14758,25 @@ func (s *Store) SearchQueueMessages(ctx context.Context, f systemType.QueueMessa
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.QueueMessageSet
if navSet, _, _, err = s.fetchFullPageOfQueueMessages(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -15064,6 +15463,25 @@ func (s *Store) SearchReminders(ctx context.Context, f systemType.ReminderFilter
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ReminderSet
if navSet, _, _, err = s.fetchFullPageOfReminders(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -15563,6 +15981,25 @@ func (s *Store) SearchReports(ctx context.Context, f systemType.ReportFilter) (s
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ReportSet
if navSet, _, _, err = s.fetchFullPageOfReports(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -16364,6 +16801,25 @@ func (s *Store) SearchResourceTranslations(ctx context.Context, f systemType.Res
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.ResourceTranslationSet
if navSet, _, _, err = s.fetchFullPageOfResourceTranslations(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -16837,6 +17293,25 @@ func (s *Store) SearchRoles(ctx context.Context, f systemType.RoleFilter) (set s
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.RoleSet
if navSet, _, _, err = s.fetchFullPageOfRoles(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -18016,6 +18491,25 @@ func (s *Store) SearchTemplates(ctx context.Context, f systemType.TemplateFilter
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.TemplateSet
if navSet, _, _, err = s.fetchFullPageOfTemplates(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
@@ -18589,6 +19083,25 @@ func (s *Store) SearchUsers(ctx context.Context, f systemType.UserFilter) (set s
return nil, f, err
}
if f.IncTotal {
// Calc total from the number of items fetched
// even if we do build the page navigation
f.Total = uint(len(set))
if f.Limit > 0 && uint(len(set)) == f.Limit {
// there are fewer items fetched then requested limit
limit := f.Limit
f.Limit = 0
var navSet systemType.UserSet
if navSet, _, _, err = s.fetchFullPageOfUsers(ctx, f, sort); err != nil {
return
} else {
f.Total = uint(len(navSet))
f.Limit = limit
}
}
}
return set, f, nil
}
+26 -5
View File
@@ -51,6 +51,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
@@ -233,6 +236,7 @@ endpoints:
- { type: "uint", name: "archived", title: "Exclude (0, default), include (1) or return only (2) archived roles" }
- { type: "map[string]string", name: "labels", title: "Labels", parser: "label.ParseStrings" }
- { type: "uint", name: "limit", title: "Limit" }
- { name: "incTotal", type: "bool", title: "Include total counter" }
- { type: "string", name: "pageCursor", title: "Page cursor" }
- { type: "string", name: "sort", title: "Sort items" }
- name: create
@@ -478,6 +482,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
@@ -852,6 +859,9 @@ endpoints:
- name: deleted
title: Exclude (0, default), include (1) or return only (2) deleted connections
type: uint
- type: bool
name: incTotal
title: Include total counter
- name: create
method: POST
title: Create connection
@@ -934,6 +944,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
@@ -1470,6 +1483,9 @@ endpoints:
- name: limit
type: uint
title: Limit
- type: bool
name: incTotal
title: Include total counter
- name: pageCursor
type: string
title: Page cursor
@@ -1637,6 +1653,9 @@ endpoints:
- type: uint
name: limit
title: Limit
- type: bool
name: incTotal
title: Include total counter
- type: string
name: pageCursor
title: Page cursor
@@ -1845,11 +1864,12 @@ endpoints:
path: "/"
parameters:
get:
- { type: string, name: query, required: false, title: Search query }
- { type: uint, name: limit, required: false, title: Limit }
- { type: string, name: pageCursor, required: false, title: Page cursor }
- { type: string, name: sort, required: false, title: Sort items }
- { type: uint, name: deleted, required: false, title: Exclude (0, default), include (1) or return only (2) deleted queues }
- { type: string, name: query, title: Search query }
- { type: uint, name: limit, title: Limit }
- { type: bool, name: incTotal, title: Include total counter }
- { type: string, name: pageCursor, title: Page cursor }
- { type: string, name: sort, title: Sort items }
- { type: uint, name: deleted, title: Exclude (0, default), include (1) or return only (2) deleted queues }
- name: create
method: POST
title: Create messaging queue
@@ -1912,6 +1932,7 @@ endpoints:
- { name: disabled, type: "uint64", title: "Exclude (0, default), include (1) or return only (2) disabled routes" }
- { name: labels, type: "map[string]string", title: "Labels", parser: "label.ParseStrings" }
- { name: limit, type: "uint", title: "Limit" }
- { name: incTotal, type: "bool", title: "Include total counter" }
- { name: pageCursor, type: "string", title: "Page cursor" }
- { name: sort, type: "string", title: "Sort items" }
- name: create
+2
View File
@@ -71,6 +71,8 @@ func (ctrl *ApigwRoute) List(ctx context.Context, r *request.ApigwRouteList) (in
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -84,6 +84,8 @@ func (ctrl *Application) List(ctx context.Context, r *request.ApplicationList) (
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -77,6 +77,8 @@ func (ctrl *AuthClient) List(ctx context.Context, r *request.AuthClientList) (in
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -92,6 +92,8 @@ func (ctrl DalConnection) List(ctx context.Context, r *request.DalConnectionList
f.Deleted = filter.StateInclusive
}
f.IncTotal = r.IncTotal
dalConnections, err = ctrl.collectConnections(ctx, f)
if err != nil {
return nil, err
+2
View File
@@ -67,6 +67,8 @@ func (ctrl *Queue) List(ctx context.Context, r *request.QueuesList) (interface{}
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -81,6 +81,8 @@ func (ctrl *Report) List(ctx context.Context, r *request.ReportList) (interface{
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+17
View File
@@ -66,6 +66,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -172,6 +177,7 @@ func (r ApigwRouteList) Auditable() map[string]interface{} {
"disabled": r.Disabled,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -207,6 +213,11 @@ func (r ApigwRouteList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r ApigwRouteList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r ApigwRouteList) GetPageCursor() string {
return r.PageCursor
@@ -270,6 +281,12 @@ func (r *ApigwRouteList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -71,6 +71,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -258,6 +263,7 @@ func (r ApplicationList) Auditable() map[string]interface{} {
"flags": r.Flags,
"incFlags": r.IncFlags,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -298,6 +304,11 @@ func (r ApplicationList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r ApplicationList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r ApplicationList) GetPageCursor() string {
return r.PageCursor
@@ -367,6 +378,12 @@ func (r *ApplicationList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -57,6 +57,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -235,6 +240,7 @@ func (r AuthClientList) Auditable() map[string]interface{} {
"deleted": r.Deleted,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -260,6 +266,11 @@ func (r AuthClientList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r AuthClientList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r AuthClientList) GetPageCursor() string {
return r.PageCursor
@@ -306,6 +317,12 @@ func (r *AuthClientList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -54,6 +54,11 @@ type (
//
// Exclude (0, default), include (1) or return only (2) deleted connections
Deleted uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
}
DalConnectionCreate struct {
@@ -139,6 +144,7 @@ func (r DalConnectionList) Auditable() map[string]interface{} {
"handle": r.Handle,
"type": r.Type,
"deleted": r.Deleted,
"incTotal": r.IncTotal,
}
}
@@ -162,6 +168,11 @@ func (r DalConnectionList) GetDeleted() uint {
return r.Deleted
}
// Auditable returns all auditable/loggable parameters
func (r DalConnectionList) GetIncTotal() bool {
return r.IncTotal
}
// Fill processes request and fills internal variables
func (r *DalConnectionList) Fill(req *http.Request) (err error) {
@@ -198,6 +209,12 @@ func (r *DalConnectionList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
}
return err
+17
View File
@@ -45,6 +45,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -132,6 +137,7 @@ func (r QueuesList) Auditable() map[string]interface{} {
return map[string]interface{}{
"query": r.Query,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
"deleted": r.Deleted,
@@ -148,6 +154,11 @@ func (r QueuesList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r QueuesList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r QueuesList) GetPageCursor() string {
return r.PageCursor
@@ -182,6 +193,12 @@ func (r *QueuesList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -57,6 +57,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -200,6 +205,7 @@ func (r ReportList) Auditable() map[string]interface{} {
"deleted": r.Deleted,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -225,6 +231,11 @@ func (r ReportList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r ReportList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r ReportList) GetPageCursor() string {
return r.PageCursor
@@ -271,6 +282,12 @@ func (r *ReportList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -66,6 +66,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -270,6 +275,7 @@ func (r RoleList) Auditable() map[string]interface{} {
"archived": r.Archived,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -305,6 +311,11 @@ func (r RoleList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r RoleList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r RoleList) GetPageCursor() string {
return r.PageCursor
@@ -363,6 +374,12 @@ func (r *RoleList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -76,6 +76,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -244,6 +249,7 @@ func (r TemplateList) Auditable() map[string]interface{} {
"deleted": r.Deleted,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -289,6 +295,11 @@ func (r TemplateList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r TemplateList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r TemplateList) GetPageCursor() string {
return r.PageCursor
@@ -359,6 +370,12 @@ func (r *TemplateList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+17
View File
@@ -101,6 +101,11 @@ type (
// Limit
Limit uint
// IncTotal GET parameter
//
// Include total counter
IncTotal bool
// PageCursor GET parameter
//
// Page cursor
@@ -345,6 +350,7 @@ func (r UserList) Auditable() map[string]interface{} {
"suspended": r.Suspended,
"labels": r.Labels,
"limit": r.Limit,
"incTotal": r.IncTotal,
"pageCursor": r.PageCursor,
"sort": r.Sort,
}
@@ -415,6 +421,11 @@ func (r UserList) GetLimit() uint {
return r.Limit
}
// Auditable returns all auditable/loggable parameters
func (r UserList) GetIncTotal() bool {
return r.IncTotal
}
// Auditable returns all auditable/loggable parameters
func (r UserList) GetPageCursor() string {
return r.PageCursor
@@ -525,6 +536,12 @@ func (r *UserList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["pageCursor"]; ok && len(val) > 0 {
r.PageCursor, err = val[0], nil
if err != nil {
+2 -1
View File
@@ -2,7 +2,6 @@ package rest
import (
"context"
"github.com/cortezaproject/corteza-server/pkg/api"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/corredor"
@@ -80,6 +79,8 @@ func (ctrl Role) List(ctx context.Context, r *request.RoleList) (interface{}, er
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -85,6 +85,8 @@ func (ctrl *Template) List(ctx context.Context, r *request.TemplateList) (interf
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}
+2
View File
@@ -101,6 +101,8 @@ func (ctrl User) List(ctx context.Context, r *request.UserList) (interface{}, er
return nil, err
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
return nil, err
}