From e7805e23f450495cfa744604eb3ca1c4bfc96138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hornych?= Date: Mon, 6 Nov 2023 20:09:02 +0100 Subject: [PATCH 1/3] feat(#62): allow to display non-representative attributes in visualiser when certain criteria is met --- .../evitaql-result-visualiser.service.ts | 23 ++++++++++--------- .../graphql-result-visualiser.service.ts | 18 +++++++++------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/services/editor/result-visualiser/evitaql-result-visualiser.service.ts b/src/services/editor/result-visualiser/evitaql-result-visualiser.service.ts index 74ad3122..99ec3a7a 100644 --- a/src/services/editor/result-visualiser/evitaql-result-visualiser.service.ts +++ b/src/services/editor/result-visualiser/evitaql-result-visualiser.service.ts @@ -61,14 +61,11 @@ export class EvitaQLResultVisualiserService extends JsonResultVisualiserService return undefined } - const actualRepresentativeAttributes: (string | undefined)[] = [] + const possibleAttributes: [any, boolean][] = [] const globalAttributes: Result = entityResult['attributes']?.['global'] || {} for (const attributeName in globalAttributes) { - if (!representativeAttributes.includes(attributeName)) { - continue; - } - actualRepresentativeAttributes.push(this.toPrintableAttributeValue(globalAttributes[attributeName])) + possibleAttributes.push([globalAttributes[attributeName], representativeAttributes.includes(attributeName)]) } const localizedAttributes: Result = entityResult['attributes']?.['localized'] || {} @@ -78,17 +75,21 @@ export class EvitaQLResultVisualiserService extends JsonResultVisualiserService const locale: string = localizedAttributesLocales[0] const attributesInLocale: Result = localizedAttributes[locale] for (const attributeName in attributesInLocale) { - if (!representativeAttributes.includes(attributeName)) { - continue; - } - actualRepresentativeAttributes.push(this.toPrintableAttributeValue(attributesInLocale[attributeName])) + possibleAttributes.push([attributesInLocale[attributeName], representativeAttributes.includes(attributeName)]) } } - if (actualRepresentativeAttributes.length === 0) { + if (possibleAttributes.length === 0) { return undefined + } else if (possibleAttributes.length <= 3) { + return possibleAttributes.map(it => this.toPrintableAttributeValue(it[0])).join(', ') + } else { + // if there are too many attributes, we only print the representative ones + return possibleAttributes + .filter(it => it[1]) + .map(it => this.toPrintableAttributeValue(it[0])) + .join(', ') } - return actualRepresentativeAttributes.filter(it => it != undefined).join(', ') } getFacetSummaryService(): FacetSummaryVisualiserService { diff --git a/src/services/editor/result-visualiser/graphql-result-visualiser.service.ts b/src/services/editor/result-visualiser/graphql-result-visualiser.service.ts index 65482ba6..eee482eb 100644 --- a/src/services/editor/result-visualiser/graphql-result-visualiser.service.ts +++ b/src/services/editor/result-visualiser/graphql-result-visualiser.service.ts @@ -67,19 +67,23 @@ export class GraphQLResultVisualiserService extends JsonResultVisualiserService return undefined } - const actualRepresentativeAttributes: (string | undefined)[] = [] + const possibleAttributes: [any, boolean][] = [] const attributes = entityResult['attributes'] || {} for (const attributeName in attributes) { - if (!representativeAttributes.includes(attributeName) && attributeName !== 'title') { - continue; - } - actualRepresentativeAttributes.push(this.toPrintableAttributeValue(attributes[attributeName])) + possibleAttributes.push([attributes[attributeName], representativeAttributes.includes(attributeName)]) } - if (actualRepresentativeAttributes.length === 0) { + if (possibleAttributes.length === 0) { return undefined + } else if (possibleAttributes.length <= 3) { + return possibleAttributes.map(it => this.toPrintableAttributeValue(it[0])).join(', ') + } else { + // if there are too many attributes, we only print the representative ones + return possibleAttributes + .filter(it => it[1]) + .map(it => this.toPrintableAttributeValue(it[0])) + .join(', ') } - return actualRepresentativeAttributes.filter(it => it != undefined).join(', ') } getFacetSummaryService(): FacetSummaryVisualiserService { From 10e38f2a4b4e0488fd20b38139a910f72880bc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hornych?= Date: Tue, 7 Nov 2023 08:23:25 +0100 Subject: [PATCH 2/3] fix(#62): console query execution loading state is not finished right after response is returned --- .../lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue | 3 ++- .../lab/editor/graphql-console/LabEditorGraphQLConsole.vue | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue b/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue index 81074d99..5bbaa3f4 100644 --- a/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue +++ b/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue @@ -63,11 +63,12 @@ async function executeQuery(): Promise { loading.value = true try { resultCode.value = await evitaQLConsoleService.executeEvitaQLQuery(props.params.dataPointer, queryCode.value, JSON.parse(variablesCode.value)) + loading.value = false enteredQueryCode.value = queryCode.value } catch (error: any) { toaster.error(error) + loading.value = false } - loading.value = false } emit('ready') diff --git a/src/components/lab/editor/graphql-console/LabEditorGraphQLConsole.vue b/src/components/lab/editor/graphql-console/LabEditorGraphQLConsole.vue index cb4c58d4..0226a57d 100644 --- a/src/components/lab/editor/graphql-console/LabEditorGraphQLConsole.vue +++ b/src/components/lab/editor/graphql-console/LabEditorGraphQLConsole.vue @@ -97,11 +97,12 @@ async function executeQuery(): Promise { loading.value = true try { resultCode.value = await graphQLConsoleService.executeGraphQLQuery(props.params.instancePointer, queryCode.value, JSON.parse(variablesCode.value)) + loading.value = false enteredQueryCode.value = queryCode.value } catch (error: any) { + loading.value = false toaster.error(error) } - loading.value = false } function initializeSchemaEditor(): void { From 3a25dd0c0195d8aa4cff2b61c82ba7d02ab41ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hornych?= Date: Tue, 7 Nov 2023 08:25:22 +0100 Subject: [PATCH 3/3] perf(#62): temporary "fix" to performance issue when on some machines the visualiser is getting slowly slower when executing more queries So far we think it has something to do with the code editor and visualiser being live at the same time. This fix should make sure that only one window is present at a single moment. --- .../lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue | 2 ++ .../lab/editor/graphql-console/LabEditorGraphQLConsole.vue | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue b/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue index 5bbaa3f4..e8719424 100644 --- a/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue +++ b/src/components/lab/editor/evitaql-console/LabEditorEvitaQLConsole.vue @@ -141,6 +141,7 @@ if (props.params.executeOnOpen) { >