From 04565d497e1e2ce347aa94e8e7f5ba0f00624e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Mon, 2 Nov 2020 06:25:54 +0100 Subject: [PATCH] Templating: Speeds up certain variable queries for Postgres, MySql and MSSql (#28686) --- public/app/plugins/datasource/mssql/response_parser.ts | 9 ++++----- public/app/plugins/datasource/mysql/response_parser.ts | 9 ++++----- .../app/plugins/datasource/postgres/response_parser.ts | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/public/app/plugins/datasource/mssql/response_parser.ts b/public/app/plugins/datasource/mssql/response_parser.ts index d56ef88d0ff..ca456ebc9bf 100644 --- a/public/app/plugins/datasource/mssql/response_parser.ts +++ b/public/app/plugins/datasource/mssql/response_parser.ts @@ -69,14 +69,13 @@ export default class ResponseParser { for (let i = 0; i < rows.length; i++) { for (let j = 0; j < rows[i].length; j++) { - const value = rows[i][j]; - if (res.indexOf(value) === -1) { - res.push(value); - } + res.push(rows[i][j]); } } - return _.map(res, value => { + const unique = Array.from(new Set(res)); + + return _.map(unique, value => { return { text: value }; }); } diff --git a/public/app/plugins/datasource/mysql/response_parser.ts b/public/app/plugins/datasource/mysql/response_parser.ts index 48c4d3a5b87..b3bb6a1aa99 100644 --- a/public/app/plugins/datasource/mysql/response_parser.ts +++ b/public/app/plugins/datasource/mysql/response_parser.ts @@ -90,14 +90,13 @@ export default class ResponseParser { for (let i = 0; i < rows.length; i++) { for (let j = 0; j < rows[i].length; j++) { - const value = rows[i][j]; - if (res.indexOf(value) === -1) { - res.push(value); - } + res.push(rows[i][j]); } } - return _.map(res, value => { + const unique = Array.from(new Set(res)); + + return _.map(unique, value => { return { text: value }; }); } diff --git a/public/app/plugins/datasource/postgres/response_parser.ts b/public/app/plugins/datasource/postgres/response_parser.ts index f4e3485a7ca..79401560f22 100644 --- a/public/app/plugins/datasource/postgres/response_parser.ts +++ b/public/app/plugins/datasource/postgres/response_parser.ts @@ -72,14 +72,13 @@ export default class ResponseParser { for (let i = 0; i < rows.length; i++) { for (let j = 0; j < rows[i].length; j++) { - const value = rows[i][j]; - if (res.indexOf(value) === -1) { - res.push(value); - } + res.push(rows[i][j]); } } - return _.map(res, value => { + const unique = Array.from(new Set(res)); + + return _.map(unique, value => { return { text: value }; }); }