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

Method GetPendingTasks

inventory/task.go:165–187  ·  view source on GitHub ↗
(ctx context.Context, taskType ...string)

Source from the content-addressed store, hash-verified

163}
164
165func (c *taskClient) GetPendingTasks(ctx context.Context, taskType ...string) ([]*ent.Task, error) {
166 tasks, err := withTaskEagerLoading(ctx, c.client.Task.Query()).
167 Where(task.StatusIn(task.StatusProcessing, task.StatusQueued, task.StatusSuspending)).
168 Where(task.TypeIn(taskType...)).
169 All(ctx)
170 if err != nil {
171 return nil, err
172 }
173
174 // Anonymous user is not loaded by default, so we need to load it manually.
175 userClient := NewUserClient(c.client)
176 anonymous, err := userClient.AnonymousUser(ctx)
177 for _, t := range tasks {
178 if t.UserTasks == 0 {
179 if err != nil {
180 return nil, err
181 }
182 t.SetUser(anonymous)
183 }
184 }
185
186 return tasks, nil
187}
188
189func (c *taskClient) GetTaskByID(ctx context.Context, taskID int) (*ent.Task, error) {
190 return withTaskEagerLoading(ctx, c.client.Task.Query()).

Callers

nothing calls this directly

Calls 9

AnonymousUserMethod · 0.95
StatusInFunction · 0.92
TypeInFunction · 0.92
withTaskEagerLoadingFunction · 0.85
NewUserClientFunction · 0.70
AllMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45
SetUserMethod · 0.45

Tested by

no test coverage detected