-
Notifications
You must be signed in to change notification settings - Fork 35
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
✨ Add bulk cancel functionality for analyses #769
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ const ( | |
TaskBucketContentRoot = TaskBucketRoot + "/*" + Wildcard | ||
TaskSubmitRoot = TaskRoot + "/submit" | ||
TaskCancelRoot = TaskRoot + "/cancel" | ||
TaskCancelListRoot = TasksRoot + "/cancel/list" | ||
) | ||
|
||
const ( | ||
|
@@ -59,6 +60,7 @@ func (h TaskHandler) AddRoutes(e *gin.Engine) { | |
// Actions | ||
routeGroup.PUT(TaskSubmitRoot, Transaction, h.Submit) | ||
routeGroup.PUT(TaskCancelRoot, h.Cancel) | ||
routeGroup.PUT(TaskCancelListRoot, h.CancelList) | ||
// Bucket | ||
routeGroup = e.Group("/") | ||
routeGroup.Use(Required("tasks.bucket")) | ||
|
@@ -468,13 +470,13 @@ func (h TaskHandler) Submit(ctx *gin.Context) { | |
h.Update(ctx) | ||
} | ||
|
||
// Cancel godoc | ||
// @summary Cancel a task. | ||
// @description Cancel a task. | ||
// @tags tasks | ||
// @success 202 | ||
// @router /tasks/{id}/cancel [put] | ||
// @param id path int true "Task ID" | ||
// // Cancel godoc | ||
// // @summary Cancel a task. | ||
// // @description Cancel a task. | ||
// // @tags tasks | ||
// // @success 202 | ||
// // @router /tasks/{id}/cancel [put] | ||
// // @param id path int true "Task ID" | ||
func (h TaskHandler) Cancel(ctx *gin.Context) { | ||
id := h.pk(ctx) | ||
rtx := RichContext(ctx) | ||
|
@@ -487,6 +489,35 @@ func (h TaskHandler) Cancel(ctx *gin.Context) { | |
h.Status(ctx, http.StatusAccepted) | ||
} | ||
|
||
// CancelList godoc | ||
// @summary Cancel multiple tasks. | ||
// @description Cancel multiple tasks by IDs. | ||
// @tags tasks | ||
// @success 202 | ||
// @router /tasks/cancel/list [put] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantically, I think it would be more correct for the PUT to be against the collection because the action is updating the collection. Ex: PUT Better yet, PUT |
||
// @param tasks body []uint true "List of Task IDs" | ||
func (h TaskHandler) CancelList(ctx *gin.Context) { | ||
ids := []uint{} | ||
|
||
if err := h.Bind(ctx, &ids); err != nil { | ||
_ = ctx.Error(err) | ||
return | ||
} | ||
|
||
rtx := RichContext(ctx) | ||
|
||
for _, id := range ids { | ||
err := rtx.TaskManager.Cancel(h.DB(ctx), id) | ||
if err != nil { | ||
_ = ctx.Error(err) | ||
return | ||
} | ||
} | ||
|
||
h.Status(ctx, http.StatusAccepted) | ||
} | ||
|
||
|
||
// BucketGet godoc | ||
// @summary Get bucket content by ID and path. | ||
// @description Get bucket content by ID and path. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were the additional
//
added? ^