---------- exact-match resolvers ---------- All ref resolution is exact match on slug (case-insensitive). ResolveTask resolves a ref to exactly one task by slug. includeArchived controls whether archived rows are eligible.
(db *sql.DB, ref string, includeArchived bool)
| 15 | // ResolveTask resolves a ref to exactly one task by slug. |
| 16 | // includeArchived controls whether archived rows are eligible. |
| 17 | func ResolveTask(db *sql.DB, ref string, includeArchived bool) (*flowdb.Task, error) { |
| 18 | ref = strings.TrimSpace(ref) |
| 19 | if ref == "" { |
| 20 | return nil, fmt.Errorf("empty task ref") |
| 21 | } |
| 22 | |
| 23 | t, err := flowdb.GetTask(db, ref) |
| 24 | if err != nil { |
| 25 | if errors.Is(err, sql.ErrNoRows) { |
| 26 | return nil, fmt.Errorf("no task matching %q", ref) |
| 27 | } |
| 28 | return nil, err |
| 29 | } |
| 30 | if !includeArchived && t.ArchivedAt.Valid { |
| 31 | return nil, fmt.Errorf("task %q is archived", ref) |
| 32 | } |
| 33 | return t, nil |
| 34 | } |
| 35 | |
| 36 | // ResolveProject resolves a ref to exactly one project by slug. |
| 37 | func ResolveProject(db *sql.DB, ref string, includeArchived bool) (*flowdb.Project, error) { |
no test coverage detected