Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checklist API performance on default tenants and email invitations #4526

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/backend-core/src/db/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
* 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
if (env.isTest()) {
return getCouch().allDbs()
Expand All @@ -197,7 +200,7 @@ exports.getAllDbs = async () => {
}
let couchUrl = `${exports.getCouchUrl()}/_all_dbs`
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:
// - single tenancy
// - default tenant
Expand Down Expand Up @@ -225,13 +228,13 @@ exports.getAllDbs = async () => {
*
* @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()
let tenantId = getTenantId()
if (!env.MULTI_TENANCY && !tenantId) {
tenantId = DEFAULT_TENANT_ID
}
let dbs = await exports.getAllDbs()
let dbs = await exports.getAllDbs({ efficient })
const appDbNames = dbs.filter(dbName => {
const split = dbName.split(SEPARATOR)
// it is an app, check the tenantId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
let createUserModal
let basicOnboardingModal

function openBasicOnoboardingModal() {
function openBasicOnboardingModal() {
createUserModal.hide()
basicOnboardingModal.show()
}
Expand Down Expand Up @@ -91,7 +91,7 @@
</Layout>

<Modal bind:this={createUserModal}>
<AddUserModal on:change={openBasicOnoboardingModal} />
<AddUserModal on:change={openBasicOnboardingModal} />
</Modal>
<Modal bind:this={basicOnboardingModal}><BasicOnboardingModal {email} /></Modal>

Expand Down
4 changes: 2 additions & 2 deletions packages/builder/src/stores/portal/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export function createUsersStore() {
}

async function invite({ email, builder, admin }) {
await API.inviteUser({
return API.inviteUser({
aptkingston marked this conversation as resolved.
Show resolved Hide resolved
email,
builder,
admin,
})
}

async function acceptInvite(inviteCode, password) {
await API.acceptInvite({
return API.acceptInvite({
aptkingston marked this conversation as resolved.
Show resolved Hide resolved
inviteCode,
password,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend-core/src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 password the password for the newly created user
*/
acceptInvitation: async ({ inviteCode, password }) => {
acceptInvite: async ({ inviteCode, password }) => {
return await API.post({
url: "/api/global/users/invite/accept",
body: {
Expand Down
8 changes: 6 additions & 2 deletions packages/worker/src/api/controllers/global/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,16 @@ exports.destroy = async function (ctx) {

exports.configChecklist = async function (ctx) {
const db = getGlobalDB()
const tenantId = getTenantId()

try {
// TODO: Watch get started video

// Apps exist
const apps = await getAllApps({ idsOnly: true })
let apps = []
if (!env.MULTI_TENANCY || tenantId) {
// Apps exist
apps = await getAllApps({ idsOnly: true, efficient: true })
}

// They have set up SMTP
const smtpConfig = await getScopedFullConfig(db, {
Expand Down