code review

This commit is contained in:
Martin McKeaveney 2020-10-09 10:46:38 +01:00
parent c9f791f250
commit c885382225
3 changed files with 11 additions and 3 deletions

View File

@ -4,6 +4,7 @@ const AWS = require("aws-sdk")
const fetch = require("node-fetch")
const { budibaseAppsDir } = require("../../../utilities/budibaseDir")
const PouchDB = require("../../../db")
const environment = require("../../../environment")
async function invalidateCDN(cfDistribution, appId) {
const cf = new AWS.CloudFront({})
@ -24,7 +25,7 @@ async function invalidateCDN(cfDistribution, appId) {
exports.updateDeploymentQuota = async function(quota) {
const DEPLOYMENT_SUCCESS_URL =
process.env.DEPLOYMENT_CREDENTIALS_URL + "deploy/success"
environment.DEPLOYMENT_CREDENTIALS_URL + "deploy/success"
const response = await fetch(DEPLOYMENT_SUCCESS_URL, {
method: "POST",

View File

@ -5,6 +5,7 @@ const {
verifyDeployment,
updateDeploymentQuota,
} = require("./aws")
const { DocumentTypes } = require("../../../db/utils")
function replicate(local, remote) {
return new Promise((resolve, reject) => {
@ -38,8 +39,12 @@ async function replicateCouch({ instanceId, clientId, credentials }) {
async function getCurrentInstanceQuota(instanceId) {
const db = new PouchDB(instanceId)
const records = await db.allDocs({
startkey: "record:",
endkey: `record:\ufff0`,
startkey: "re:",
endkey: `re:\ufff0`,
})
const users = await db.allDocs({
startkey: DocumentTypes.USER + ,
endkey: `us:\ufff0`,
})
const existingRecords = records.rows.length

View File

@ -14,6 +14,8 @@ exports.DocumentTypes = DocumentTypes
const UNICODE_MAX = "\ufff0"
exports.UNICODE_MAX = UNICODE_MAX
/**
* If creating DB allDocs/query params with only a single top level ID this can be used, this
* is usually the case as most of our docs are top level e.g. models, automations, users and so on.