Browse Source

fix(templating): fixed unique filter after regex pass, fixes #6086

Torkel Ödegaard 9 years ago
parent
commit
9e26a4cfcb

+ 2 - 2
public/app/features/templating/query_variable.ts

@@ -115,14 +115,14 @@ export class QueryVariable implements Variable {
         if (!matches) { continue; }
         if (matches.length > 1) {
           value = matches[1];
-          text = value;
+          text = matches[1];
         }
       }
 
       options.push({text: text, value: value});
     }
 
-    options = _.uniq(options, 'value');
+    options = _.uniqBy(options, 'value');
     return this.sortVariableValues(options, this.sort);
   }
 

+ 1 - 1
public/app/features/templating/specs/variable_srv_specs.ts

@@ -250,7 +250,7 @@ describe('VariableSrv', function() {
     describeUpdateVariable('regex pattern remove duplicates', function(scenario) {
       scenario.setup(function() {
         scenario.variableModel = {type: 'query', query: 'apps.*', name: 'test'};
-        scenario.variableModel.regex = 'backend_01';
+        scenario.variableModel.regex = '/backend_01/';
         scenario.queryResult = [{text: 'apps.backend.backend_01.counters.req'}, {text: 'apps.backend.backend_01.counters.req'}];
       });