MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / FindAll

Method FindAll

app/controlplane/pkg/data/user.go:126–156  ·  view source on GitHub ↗

FindAll get all users in the system using pagination

(ctx context.Context, pagination *pagination.OffsetPaginationOpts)

Source from the content-addressed store, hash-verified

124
125// FindAll get all users in the system using pagination
126func (r *userRepo) FindAll(ctx context.Context, pagination *pagination.OffsetPaginationOpts) ([]*biz.User, int, error) {
127 ctx, span := otelx.Start(ctx, userRepoTracer, "UserRepo.FindAll")
128 defer span.End()
129
130 if pagination == nil {
131 return nil, 0, fmt.Errorf("pagination options is required")
132 }
133
134 baseQuery := r.data.DB.User.Query()
135
136 count, err := baseQuery.Count(ctx)
137 if err != nil {
138 return nil, 0, err
139 }
140
141 users, err := baseQuery.
142 Order(ent.Desc(workflow.FieldCreatedAt)).
143 Limit(pagination.Limit()).
144 Offset(pagination.Offset()).
145 All(ctx)
146 if err != nil {
147 return nil, 0, err
148 }
149
150 result := make([]*biz.User, 0, len(users))
151 for _, u := range users {
152 result = append(result, entUserToBizUser(u))
153 }
154
155 return result, count, nil
156}
157
158// HasUsersWithAccessPropertyNotSet returns the number of users with restricted access or unset access
159func (r *userRepo) HasUsersWithAccessPropertyNotSet(ctx context.Context) (bool, error) {

Callers

nothing calls this directly

Calls 9

StartFunction · 0.92
DescFunction · 0.92
entUserToBizUserFunction · 0.85
QueryMethod · 0.45
CountMethod · 0.45
AllMethod · 0.45
OffsetMethod · 0.45
LimitMethod · 0.45
OrderMethod · 0.45

Tested by

no test coverage detected