Skip to content

Commit

Permalink
fix(agents-api): fix get task query
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-mtos committed Dec 26, 2024
1 parent 798c625 commit 35344f1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions agents-api/agents_api/queries/tasks/get_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@
SELECT
t.*,
COALESCE(
jsonb_agg(
CASE WHEN w.name IS NOT NULL THEN
jsonb_build_object(
'name', w.name,
'steps', jsonb_build_array(w.step_definition)
jsonb_agg(
DISTINCT jsonb_build_object(
'name', w.name,
'steps', (
SELECT jsonb_agg(step_definition ORDER BY step_idx)
FROM workflows w2
WHERE w2.developer_id = w.developer_id
AND w2.task_id = w.task_id
AND w2.version = w.version
AND w2.name = w.name
)
END
) FILTER (WHERE w.name IS NOT NULL),
)
) FILTER (WHERE w.name IS NOT NULL),
'[]'::jsonb
) as workflows,
COALESCE(jsonb_agg(tl), '[]'::jsonb) as tools
COALESCE(
jsonb_agg(tl) FILTER (WHERE tl IS NOT NULL),
'[]'::jsonb
) as tools
FROM
tasks t
LEFT JOIN
Expand Down

0 comments on commit 35344f1

Please sign in to comment.