FindAll get all users in the system using pagination
(ctx context.Context, pagination *pagination.OffsetPaginationOpts)
| 124 | |
| 125 | // FindAll get all users in the system using pagination |
| 126 | func (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 |
| 159 | func (r *userRepo) HasUsersWithAccessPropertyNotSet(ctx context.Context) (bool, error) { |