(ctx context.Context, taskType ...string)
| 163 | } |
| 164 | |
| 165 | func (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 | |
| 189 | func (c *taskClient) GetTaskByID(ctx context.Context, taskID int) (*ent.Task, error) { |
| 190 | return withTaskEagerLoading(ctx, c.client.Task.Query()). |
nothing calls this directly
no test coverage detected