Skip to content

Commit

Permalink
Revert "Fix record fetching ending prematurely due to RBAC"
Browse files Browse the repository at this point in the history
This reverts commit 8e03ea5.
  • Loading branch information
tjerman committed Sep 29, 2023
1 parent 86c12cc commit 1e29e61
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions server/compose/dalutils/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dalutils
import (
"context"
"fmt"

"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/dal"
"github.com/cortezaproject/corteza/server/pkg/filter"
Expand Down Expand Up @@ -130,10 +129,9 @@ func drainIterator(ctx context.Context, iter dal.Iterator, mod *types.Module, f
}

var (
ok bool
fetched uint
filtered uint
r *types.Record
ok bool
fetched uint
r *types.Record
)

// Get the requested number of record
Expand All @@ -146,15 +144,13 @@ func drainIterator(ctx context.Context, iter dal.Iterator, mod *types.Module, f
for f.Limit == 0 || uint(len(set)) < f.Limit {
// reset counters every drain
fetched = 0
filtered = 0

err = WalkIterator(ctx, iter, mod, func(r *types.Record) error {
// check fetched record
if f.Check != nil {
if ok, err = f.Check(r); err != nil {
return err
} else if !ok {
filtered++
return nil
}
}
Expand All @@ -170,12 +166,11 @@ func drainIterator(ctx context.Context, iter dal.Iterator, mod *types.Module, f
return
}

total := fetched + filtered
if total == 0 || f.Limit == 0 || (0 < f.Limit && total < f.Limit) {
if fetched == 0 || f.Limit == 0 || (0 < f.Limit && fetched < f.Limit) {
// do not re-fetch if:
// 1) nothing was fetch in the previous run
// 2) there was no limit (everything was fetched)
// 3) there are less total (fetched and filtered) items then value of limit
// 3) there are less fetched items then value of limit
break
}

Expand Down

0 comments on commit 1e29e61

Please sign in to comment.