|
|
|
|
@ -95,14 +95,22 @@ func (f FolderFilter) Where() (string, []interface{}) { |
|
|
|
|
return sqlIDin("dashboard.folder_id", f.IDs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type DashboardFilter struct { |
|
|
|
|
type DashboardIDFilter struct { |
|
|
|
|
IDs []int64 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (f DashboardFilter) Where() (string, []interface{}) { |
|
|
|
|
func (f DashboardIDFilter) Where() (string, []interface{}) { |
|
|
|
|
return sqlIDin("dashboard.id", f.IDs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type DashboardFilter struct { |
|
|
|
|
UIDs []string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (f DashboardFilter) Where() (string, []interface{}) { |
|
|
|
|
return sqlUIDin("dashboard.uid", f.UIDs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type TagsFilter struct { |
|
|
|
|
Tags []string |
|
|
|
|
} |
|
|
|
|
@ -150,6 +158,21 @@ func sqlIDin(column string, ids []int64) (string, []interface{}) { |
|
|
|
|
return fmt.Sprintf("%s IN %s", column, sqlArray), params |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func sqlUIDin(column string, uids []string) (string, []interface{}) { |
|
|
|
|
length := len(uids) |
|
|
|
|
if length < 1 { |
|
|
|
|
return "", nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sqlArray := "(?" + strings.Repeat(",?", length-1) + ")" |
|
|
|
|
|
|
|
|
|
params := []interface{}{} |
|
|
|
|
for _, id := range uids { |
|
|
|
|
params = append(params, id) |
|
|
|
|
} |
|
|
|
|
return fmt.Sprintf("%s IN %s", column, sqlArray), params |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FolderWithAlertsFilter applies a filter that makes the result contain only folders that contain alert rules
|
|
|
|
|
type FolderWithAlertsFilter struct { |
|
|
|
|
} |
|
|
|
|
|