mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-28 03:23:25 +08:00
feat(scheduledtask): support filter scheduledtask with label
This commit is contained in:
@@ -75,6 +75,10 @@ type ScheduledTaskListInput struct {
|
||||
// example: tag
|
||||
LabelType string `json:"label_type"`
|
||||
|
||||
// description: filter scheduledtask binded with label
|
||||
// example: g-12345
|
||||
Label string `json:"label"`
|
||||
|
||||
// description: operation
|
||||
// example: stop
|
||||
// enum: start,stop,restart
|
||||
|
||||
@@ -98,6 +98,10 @@ func (stm *SScheduledTaskManager) ListItemFilter(ctx context.Context, q *sqlchem
|
||||
if len(input.LabelType) > 0 {
|
||||
q = q.Equals("label_type", input.LabelType)
|
||||
}
|
||||
if len(input.Label) > 0 {
|
||||
sq := ScheduledTaskLabelManager.Query("scheduled_task_id").Equals("label", input.Label).SubQuery()
|
||||
q = q.Join(sq, sqlchemy.Equals(q.Field("id"), sq.Field("scheduled_task_id")))
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user