Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hooks): delete task handler #4863

Merged
merged 2 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion engine/api/workflow/dao_data_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ func LoadAllHooks(db gorp.SqlExecutor) ([]sdk.NodeHook, error) {
}

var res []dbNodeHookData
if _, err := db.Select(&res, "select * from w_node_hook"); err != nil {
var query = `
select * from w_node_hook
where id in (
select max(id) as "id" from w_node_hook
group by uuid)
`
if _, err := db.Select(&res, query); err != nil {
if err == sql.ErrNoRows {
return nil, nil
}
Expand Down
10 changes: 5 additions & 5 deletions engine/hooks/hooks_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ func (s *Service) getTaskHandler() service.Handler {

//Load the task
t := s.Dao.FindTask(uuid)
if t != nil {
return service.WriteJSON(w, t, http.StatusOK)
if t == nil {
return sdk.ErrNotFound
}

execs, err := s.Dao.FindAllTaskExecutions(t)
Expand All @@ -287,8 +287,8 @@ func (s *Service) deleteTaskHandler() service.Handler {

//Load the task
t := s.Dao.FindTask(uuid)
if t != nil {
return service.WriteJSON(w, t, http.StatusOK)
if t == nil {
return sdk.ErrNotFound
}

//Stop the task
Expand All @@ -309,7 +309,7 @@ func (s *Service) getTaskExecutionsHandler() service.Handler {
//Load the task
t := s.Dao.FindTask(uuid)
if t == nil {
return service.WriteJSON(w, t, http.StatusOK)
return sdk.ErrNotFound
}

//Load the executions
Expand Down