Skip to content

Commit

Permalink
fix(hooks): delete task handler (#4863)
Browse files Browse the repository at this point in the history
* fix(hooks): delete task handler
* fix(api): change LoadAllHooks query to avoid duplicate
  • Loading branch information
fsamin authored and richardlt committed Jan 13, 2020
1 parent 39dccfe commit 1eb063f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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(ctx, uuid)
if t != nil {
return service.WriteJSON(w, t, http.StatusOK)
if t == nil {
return sdk.ErrNotFound
}

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

//Load the task
t := s.Dao.FindTask(ctx, 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(ctx, uuid)
if t == nil {
return service.WriteJSON(w, t, http.StatusOK)
return sdk.ErrNotFound
}

//Load the executions
Expand Down

0 comments on commit 1eb063f

Please sign in to comment.