Skip to content

Commit c089317

Browse files
nss10lbeckman314
authored andcommitted
feat: Add state filter in ListTasks (Credit: @nss10)
- Original source: 7f60650
1 parent 2da484b commit c089317

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

database/postgres/tes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ func (db *Postgres) ListTasks(ctx context.Context, req *tes.ListTasksRequest) (*
8989
paramCount++
9090
}
9191

92+
// State filter. FIXME: The logic fails to fetch the records for tasks in the UNKNOWN state, but we currently have no tasks in that state, so it isn't a problem.
93+
// We should review this logic when we add support for UNKNOWN state tasks.
94+
if req.State != tes.State_UNKNOWN {
95+
whereClauses = append(whereClauses, fmt.Sprintf("state = $%d", paramCount))
96+
args = append(args, req.State)
97+
paramCount++
98+
}
99+
92100
// Authorization filter
93101
if userInfo := server.GetUser(ctx); !userInfo.CanSeeAllTasks() {
94102
whereClauses = append(whereClauses, fmt.Sprintf("owner = $%d", paramCount))

0 commit comments

Comments
 (0)