From 5bf33fd422a0b7286e9ed5ce0c82944e54aed991 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Thu, 21 Nov 2019 09:22:05 +0100 Subject: [PATCH] Revert changes in getServices due to readability concerns --- .../server/lib/services/get_services/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/x-pack/legacy/plugins/apm/server/lib/services/get_services/index.ts b/x-pack/legacy/plugins/apm/server/lib/services/get_services/index.ts index 3345bab87361c..d9fc89062cf88 100644 --- a/x-pack/legacy/plugins/apm/server/lib/services/get_services/index.ts +++ b/x-pack/legacy/plugins/apm/server/lib/services/get_services/index.ts @@ -20,17 +20,19 @@ export type ServiceListAPIResponse = PromiseReturnType; export async function getServices( setup: Setup & SetupTimeRange & SetupUIFilters ) { - const itemsPromise = getServicesItems(setup); - const hasLegacyDataPromise = getLegacyDataStatus(setup); - const items = await itemsPromise; + const [items, hasLegacyData] = await Promise.all([ + getServicesItems(setup), + getLegacyDataStatus(setup) + ]); const noDataInCurrentTimeRange = isEmpty(items); + const hasHistoricalData = noDataInCurrentTimeRange + ? await hasHistoricalAgentData(setup) + : true; return { items, - hasHistoricalData: noDataInCurrentTimeRange - ? await hasHistoricalAgentData(setup) - : true, - hasLegacyData: await hasLegacyDataPromise + hasHistoricalData, + hasLegacyData }; }