From 16e401737d57d8e231a24eba457a68e7bae996ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 19 Mar 2021 13:51:21 +0100 Subject: [PATCH] improve database.select performance --- .../builder/src/builderStore/store/backend.js | 17 +-- packages/builder/tests/stores/backend.spec.js | 0 packages/builder/tests/testData.js | 111 ------------------ 3 files changed, 9 insertions(+), 119 deletions(-) create mode 100644 packages/builder/tests/stores/backend.spec.js delete mode 100644 packages/builder/tests/testData.js diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 0a5b9f0461..d4894cbd11 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -22,14 +22,15 @@ export const getBackendUiStore = () => { reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }), database: { select: async db => { - const tablesResponse = await api.get(`/api/tables`) - const tables = await tablesResponse.json() - const datasourcesResponse = await api.get(`/api/datasources`) - const datasources = await datasourcesResponse.json() - const queriesResponse = await api.get(`/api/queries`) - const queries = await queriesResponse.json() - const integrationsResponse = await api.get("/api/integrations") - const integrations = await integrationsResponse.json() + const [tables, datasources, queries, integrations] = await Promise.all([ + api.get(`/api/tables`).then(r => r.json()), + api.get(`/api/datasources`).then(r => r.json()), + api.get(`/api/queries`).then(r => r.json()), + api.get("/api/integrations").then(r => r.json()) + ]) + + console.log(tables) + const permissionLevels = await store.actions.permissions.fetchLevels() store.update(state => { diff --git a/packages/builder/tests/stores/backend.spec.js b/packages/builder/tests/stores/backend.spec.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/builder/tests/testData.js b/packages/builder/tests/testData.js deleted file mode 100644 index 02b4e59da2..0000000000 --- a/packages/builder/tests/testData.js +++ /dev/null @@ -1,111 +0,0 @@ -export const componentsAndScreens = () => ({ - components: [ - { - _instanceName: "TextBox", - tags: ["Text", "input"], - children: false, - props: { - size: { type: "options", options: ["small", "medium", "large"] }, - isPassword: "bool", - placeholder: "string", - label: "string", - }, - }, - { - _instanceName: "Button", - tags: ["input"], - children: true, - props: { - size: { type: "options", options: ["small", "medium", "large"] }, - css: "string", - contentText: "string", - }, - }, - { - _instanceName: "div", - tags: ["input"], - props: { - width: "number", - }, - }, - { - _instanceName: "Row View", - tags: ["row"], - props: { - data: "state", - }, - }, - ], - screens: [ - { - props: { - _component: "budibase-components/TextBox", - _instanceName: "SmallTextbox", - size: "small", - }, - }, - - { - name: "common/PasswordBox", - tags: ["mask"], - props: { - _component: "budibase-components/TextBox", - _instanceName: "PasswordBox", - isPassword: true, - size: "small", - }, - }, - - { - props: { - _component: "budibase-components/Button", - _instanceName: "PrimaryButton", - css: "btn-primary", - }, - }, - - { - route: "", - props: { - _component: "budibase-components/div", - width: 100, - _instanceName: "Screen 1", - _children: [ - { - _component: "budibase-components/Button", - contentText: "Button 1", - _instanceName: "Button 1", - }, - { - _component: "budibase-components/Button", - contentText: "Button 2", - _instanceName: "Button 2", - }, - { - _component: "budibase-components/TextBox", - _instanceName: "TextBox", - isPassword: true, - size: "small", - }, - ], - }, - }, - - { - props: { - _component: "budibase-components/div", - _instanceName: "Field", - _children: [ - { - _component: "common/SmallTextbox", - }, - ], - }, - }, - ], -}) - -export const stripStandardProps = props => { - delete props._id - delete props._styles -}