Tasks parses a search query for tasks. Supported query parameters: - owner: string (username, UUID, or 'me' for current user) - organization: string (organization UUID or name) - status: string (pending, initializing, active, paused, error, unknown)
(ctx context.Context, db database.Store, query string, actorID uuid.UUID)
| 513 | // - organization: string (organization UUID or name) |
| 514 | // - status: string (pending, initializing, active, paused, error, unknown) |
| 515 | func Tasks(ctx context.Context, db database.Store, query string, actorID uuid.UUID) (database.ListTasksParams, []codersdk.ValidationError) { |
| 516 | filter := database.ListTasksParams{ |
| 517 | OwnerID: uuid.Nil, |
| 518 | OrganizationID: uuid.Nil, |
| 519 | Status: "", |
| 520 | } |
| 521 | |
| 522 | if query == "" { |
| 523 | return filter, nil |
| 524 | } |
| 525 | |
| 526 | // Always lowercase for all searches. |
| 527 | query = strings.ToLower(query) |
| 528 | values, errors := searchTerms(query, func(term string, values url.Values) error { |
| 529 | // Default unqualified terms to owner |
| 530 | values.Add("owner", term) |
| 531 | return nil |
| 532 | }) |
| 533 | if len(errors) > 0 { |
| 534 | return filter, errors |
| 535 | } |
| 536 | |
| 537 | parser := httpapi.NewQueryParamParser() |
| 538 | filter.OwnerID = parseUser(ctx, db, parser, values, "owner", actorID) |
| 539 | filter.OrganizationID = parseOrganization(ctx, db, parser, values, "organization") |
| 540 | filter.Status = parser.String(values, "", "status") |
| 541 | |
| 542 | parser.ErrorExcessParams(values) |
| 543 | return filter, parser.Errors |
| 544 | } |
| 545 | |
| 546 | // Chats parses a search query for chats. |
| 547 | // |