1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

Adding fix in for views including internal views which shouldn't be added to view calculation.

This commit is contained in:
mike12345567 2021-02-22 16:10:29 +00:00
parent 820fe9c9a5
commit 64cfc02fa2

View file

@ -1,5 +1,12 @@
const PouchDB = require("../../../db")
const { DocumentTypes, SEPARATOR, UNICODE_MAX } = require("../../../db/utils")
const {
DocumentTypes,
SEPARATOR,
UNICODE_MAX,
ViewNames,
} = require("../../../db/utils")
const EXCLUDED_VIEWS = [ViewNames.USERS, ViewNames.LINK, ViewNames.ROUTING]
exports.getAppQuota = async function(appId) {
const db = new PouchDB(appId)
@ -19,9 +26,16 @@ exports.getAppQuota = async function(appId) {
const designDoc = await db.get("_design/database")
let views = 0
for (let viewName of Object.keys(designDoc.views)) {
if (EXCLUDED_VIEWS.indexOf(viewName) === -1) {
views++
}
}
return {
rows: existingRows,
users: existingUsers,
views: Object.keys(designDoc.views).length,
views: views,
}
}