Procházet zdrojové kódy

Minor refactoring of testdata query order PR #16122

Torkel Ödegaard před 6 roky
rodič
revize
85b0df551c
1 změnil soubory, kde provedl 11 přidání a 17 odebrání
  1. 11 17
      public/app/plugins/datasource/testdata/datasource.ts

+ 11 - 17
public/app/plugins/datasource/testdata/datasource.ts

@@ -51,25 +51,19 @@ export class TestDataDatasource implements DataSourceApi<TestDataQuery> {
 
 
         // Returns data in the order it was asked for.
         // Returns data in the order it was asked for.
         // if the response has data with different refId, it is ignored
         // if the response has data with different refId, it is ignored
-        for (let i = 0; i < queries.length; i++) {
-          const query = queries[i];
+        for (const query of queries) {
           const results = res.data.results[query.refId];
           const results = res.data.results[query.refId];
-          if (results) {
-            if (results.tables) {
-              for (const table of results.tables) {
-                data.push(table as TableData);
-              }
-            }
-            if (results.series) {
-              for (const series of results.series) {
-                data.push({
-                  target: series.name,
-                  datapoints: series.points,
-                });
-              }
-            }
-          } else {
+          if (!results) {
             console.warn('No Results for:', query);
             console.warn('No Results for:', query);
+            continue;
+          }
+
+          for (const table of results.tables || []) {
+            data.push(table as TableData);
+          }
+
+          for (const series of results.series || []) {
+            data.push({ target: series.name, datapoints: series.points });
           }
           }
         }
         }