From e61e118b251313ccad7cdc779f7000fea69151c7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Sun, 22 May 2022 18:51:13 +0100 Subject: [PATCH] query optimisation on checklist endpoint --- packages/worker/src/api/controllers/global/configs.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/worker/src/api/controllers/global/configs.js b/packages/worker/src/api/controllers/global/configs.js index 658789e90a..3799337bd5 100644 --- a/packages/worker/src/api/controllers/global/configs.js +++ b/packages/worker/src/api/controllers/global/configs.js @@ -1,6 +1,7 @@ const { generateConfigID, getConfigParams, + getGlobalUserParams, getScopedFullConfig, getAllApps, } = require("@budibase/backend-core/db") @@ -271,6 +272,14 @@ exports.configChecklist = async function (ctx) { type: Configs.OIDC, }) + // They have set up an global user + const users = await db.allDocs( + getGlobalUserParams(null, { + include_docs: true, + limit: 1, + }) + ) + ctx.body = { apps: { checked: apps.length > 0, @@ -283,7 +292,7 @@ exports.configChecklist = async function (ctx) { link: "/builder/portal/manage/email", }, adminUser: { - checked: true, + checked: users && users.rows.length >= 1, label: "Create your first user", link: "/builder/portal/manage/users", },