MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / List

Method List

inventory/task.go:202–241  ·  view source on GitHub ↗
(ctx context.Context, args *ListTaskArgs)

Source from the content-addressed store, hash-verified

200}
201
202func (c *taskClient) List(ctx context.Context, args *ListTaskArgs) (*ListTaskResult, error) {
203 q := c.client.Task.Query()
204 if args.UserID != 0 {
205 q.Where(task.UserTasks(args.UserID))
206 }
207
208 if args.Types != nil {
209 q.Where(task.TypeIn(args.Types...))
210 }
211
212 if args.Status != nil {
213 q.Where(task.StatusIn(args.Status...))
214 }
215
216 if args.CorrelationID != nil {
217 q.Where(task.CorrelationID(*args.CorrelationID))
218 }
219
220 q = withTaskEagerLoading(ctx, q)
221 var (
222 tasks []*ent.Task
223 err error
224 paginationRes *PaginationResults
225 )
226
227 if args.UseCursorPagination {
228 tasks, paginationRes, err = c.cursorPagination(ctx, q, args, 1)
229 } else {
230 tasks, paginationRes, err = c.offsetPagination(ctx, q, args, 1)
231 }
232
233 if err != nil {
234 return nil, fmt.Errorf("query failed with paginiation: %w", err)
235 }
236
237 return &ListTaskResult{
238 Tasks: tasks,
239 PaginationResults: paginationRes,
240 }, nil
241}
242
243func (c *taskClient) cursorPagination(ctx context.Context, query *ent.TaskQuery, args *ListTaskArgs, paramMargin int) ([]*ent.Task, *PaginationResults, error) {
244 pageSize := capPageSize(c.maxSQlParam, args.PageSize, paramMargin)

Callers

nothing calls this directly

Calls 9

cursorPaginationMethod · 0.95
offsetPaginationMethod · 0.95
UserTasksFunction · 0.92
TypeInFunction · 0.92
StatusInFunction · 0.92
CorrelationIDFunction · 0.92
withTaskEagerLoadingFunction · 0.85
QueryMethod · 0.45
WhereMethod · 0.45

Tested by

no test coverage detected