feat(scheduledtask): support filter scheduledtask with label

This commit is contained in:
rainzm
2021-11-18 10:04:47 +08:00
parent ae3104e980
commit b2c1fde548
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -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
}