Alerting: Update API to use folders' full paths (#81214)
* update GetUserVisibleNamespaces to use FolderSeriver * update GetNamespaceByUID to use FolderService.GetFolders * update GetAlertRulesForScheduling to use FolderService.GetFolders * Update API and GetAlertRulesForScheduling to use the folder's full path * get full path of folder in RouteTestGrafanaRuleConfig * fix escaping of titles for MySQL
This commit is contained in:
@@ -530,10 +530,14 @@ func (ss *sqlStore) GetDescendants(ctx context.Context, orgID int64, ancestor_ui
|
||||
}
|
||||
|
||||
func getFullpathSQL(dialect migrator.Dialect) string {
|
||||
escaped := "\\/"
|
||||
if dialect.DriverName() == migrator.MySQL {
|
||||
escaped = "\\\\/"
|
||||
}
|
||||
concatCols := make([]string, 0, folder.MaxNestedFolderDepth)
|
||||
concatCols = append(concatCols, "COALESCE(REPLACE(f0.title, '/', '\\/'), '')")
|
||||
concatCols = append(concatCols, fmt.Sprintf("COALESCE(REPLACE(f0.title, '/', '%s'), '')", escaped))
|
||||
for i := 1; i <= folder.MaxNestedFolderDepth; i++ {
|
||||
concatCols = append([]string{fmt.Sprintf("COALESCE(REPLACE(f%d.title, '/', '\\/'), '')", i), "'/'"}, concatCols...)
|
||||
concatCols = append([]string{fmt.Sprintf("COALESCE(REPLACE(f%d.title, '/', '%s'), '')", i, escaped), "'/'"}, concatCols...)
|
||||
}
|
||||
return dialect.Concat(concatCols...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user