Skip to content

Commit

Permalink
fix(api): workflow search sort runs (#6556)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored May 23, 2023
1 parent e9852c2 commit ca43679
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions engine/api/workflow/dao_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,13 @@ func LoadLastRun(ctx context.Context, db gorp.SqlExecutor, projectkey, workflown

// LoadLastRuns returns the last run per workflowIDs
func LoadLastRuns(ctx context.Context, db gorp.SqlExecutor, workflowIDs []int64, limit int) ([]sdk.WorkflowRun, error) {
query := fmt.Sprintf(`select %s
from workflow_run
where workflow_run.workflow_id = ANY($1)
order by workflow_run.workflow_id, workflow_run.num desc limit $2`, wfRunfields)
query := fmt.Sprintf(`
SELECT %s
FROM workflow_run
WHERE workflow_run.workflow_id = ANY($1)
ORDER BY workflow_run.start DESC, workflow_run.num DESC
LIMIT $2
`, wfRunfields)
return loadRuns(ctx, db, query, pq.Int64Array(workflowIDs), limit)
}

Expand Down

0 comments on commit ca43679

Please sign in to comment.