1
0
Fork 0
mirror of synced 2024-08-17 11:01:26 +12:00

Merge pull request #4526 from Budibase/fix/checklist-perf

Checklist API performance on default tenants
This commit is contained in:
Michael Drury 2022-02-16 13:44:54 +00:00 committed by GitHub
commit f0c3358d77
5 changed files with 19 additions and 12 deletions

View file

@ -179,8 +179,11 @@ exports.getStartEndKeyURL = (base, baseKey, tenantId = null) => {
/** /**
* if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing * if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing
* when using Pouch it will use the pouchdb-all-dbs package. * when using Pouch it will use the pouchdb-all-dbs package.
* opts.efficient can be provided to make sure this call is always quick in a multi-tenant environment,
* but it may not be 100% accurate in full efficiency mode (some tenantless apps may be missed).
*/ */
exports.getAllDbs = async () => { exports.getAllDbs = async (opts = { efficient: false }) => {
const efficient = opts && opts.efficient
// specifically for testing we use the pouch package for this // specifically for testing we use the pouch package for this
if (env.isTest()) { if (env.isTest()) {
return getCouch().allDbs() return getCouch().allDbs()
@ -197,7 +200,7 @@ exports.getAllDbs = async () => {
} }
let couchUrl = `${exports.getCouchUrl()}/_all_dbs` let couchUrl = `${exports.getCouchUrl()}/_all_dbs`
let tenantId = getTenantId() let tenantId = getTenantId()
if (!env.MULTI_TENANCY || tenantId === DEFAULT_TENANT_ID) { if (!env.MULTI_TENANCY || (!efficient && tenantId === DEFAULT_TENANT_ID)) {
// just get all DBs when: // just get all DBs when:
// - single tenancy // - single tenancy
// - default tenant // - default tenant
@ -225,13 +228,13 @@ exports.getAllDbs = async () => {
* *
* @return {Promise<object[]>} returns the app information document stored in each app database. * @return {Promise<object[]>} returns the app information document stored in each app database.
*/ */
exports.getAllApps = async ({ dev, all, idsOnly } = {}) => { exports.getAllApps = async ({ dev, all, idsOnly, efficient } = {}) => {
const CouchDB = getCouch() const CouchDB = getCouch()
let tenantId = getTenantId() let tenantId = getTenantId()
if (!env.MULTI_TENANCY && !tenantId) { if (!env.MULTI_TENANCY && !tenantId) {
tenantId = DEFAULT_TENANT_ID tenantId = DEFAULT_TENANT_ID
} }
let dbs = await exports.getAllDbs() let dbs = await exports.getAllDbs({ efficient })
const appDbNames = dbs.filter(dbName => { const appDbNames = dbs.filter(dbName => {
const split = dbName.split(SEPARATOR) const split = dbName.split(SEPARATOR)
// it is an app, check the tenantId // it is an app, check the tenantId

View file

@ -43,7 +43,7 @@
let createUserModal let createUserModal
let basicOnboardingModal let basicOnboardingModal
function openBasicOnoboardingModal() { function openBasicOnboardingModal() {
createUserModal.hide() createUserModal.hide()
basicOnboardingModal.show() basicOnboardingModal.show()
} }
@ -91,7 +91,7 @@
</Layout> </Layout>
<Modal bind:this={createUserModal}> <Modal bind:this={createUserModal}>
<AddUserModal on:change={openBasicOnoboardingModal} /> <AddUserModal on:change={openBasicOnboardingModal} />
</Modal> </Modal>
<Modal bind:this={basicOnboardingModal}><BasicOnboardingModal {email} /></Modal> <Modal bind:this={basicOnboardingModal}><BasicOnboardingModal {email} /></Modal>

View file

@ -11,7 +11,7 @@ export function createUsersStore() {
} }
async function invite({ email, builder, admin }) { async function invite({ email, builder, admin }) {
await API.inviteUser({ return API.inviteUser({
email, email,
builder, builder,
admin, admin,
@ -19,7 +19,7 @@ export function createUsersStore() {
} }
async function acceptInvite(inviteCode, password) { async function acceptInvite(inviteCode, password) {
await API.acceptInvite({ return API.acceptInvite({
inviteCode, inviteCode,
password, password,
}) })

View file

@ -113,11 +113,11 @@ export const buildUserEndpoints = API => ({
}, },
/** /**
* Accepts an invitation to join the platform and creates a user. * Accepts an invite to join the platform and creates a user.
* @param inviteCode the invite code sent in the email * @param inviteCode the invite code sent in the email
* @param password the password for the newly created user * @param password the password for the newly created user
*/ */
acceptInvitation: async ({ inviteCode, password }) => { acceptInvite: async ({ inviteCode, password }) => {
return await API.post({ return await API.post({
url: "/api/global/users/invite/accept", url: "/api/global/users/invite/accept",
body: { body: {

View file

@ -246,12 +246,16 @@ exports.destroy = async function (ctx) {
exports.configChecklist = async function (ctx) { exports.configChecklist = async function (ctx) {
const db = getGlobalDB() const db = getGlobalDB()
const tenantId = getTenantId()
try { try {
// TODO: Watch get started video // TODO: Watch get started video
// Apps exist let apps = []
const apps = await getAllApps({ idsOnly: true }) if (!env.MULTI_TENANCY || tenantId) {
// Apps exist
apps = await getAllApps({ idsOnly: true, efficient: true })
}
// They have set up SMTP // They have set up SMTP
const smtpConfig = await getScopedFullConfig(db, { const smtpConfig = await getScopedFullConfig(db, {