|
|
@ -1,7 +1,7 @@ |
|
|
|
import { Request, Response } from 'express'; |
|
|
|
import { Request, Response } from 'express'; |
|
|
|
import Project from '../../models/Project'; |
|
|
|
import Project from '../../models/Project'; |
|
|
|
import { ModelTypes, ProjectListType, UITypes } from 'nocodb-sdk'; |
|
|
|
import { ModelTypes, ProjectListType, UITypes } from 'nocodb-sdk'; |
|
|
|
|
|
|
|
import DOMPurify from 'isomorphic-dompurify'; |
|
|
|
import { PagedResponseImpl } from '../helpers/PagedResponse'; |
|
|
|
import { PagedResponseImpl } from '../helpers/PagedResponse'; |
|
|
|
import syncMigration from '../helpers/syncMigration'; |
|
|
|
import syncMigration from '../helpers/syncMigration'; |
|
|
|
import { IGNORE_TABLES } from '../../utils/common/BaseApiBuilder'; |
|
|
|
import { IGNORE_TABLES } from '../../utils/common/BaseApiBuilder'; |
|
|
@ -98,7 +98,8 @@ async function projectCreate(req: Request<any, any>, res) { |
|
|
|
if (await Project.getByTitle(projectBody?.title)) { |
|
|
|
if (await Project.getByTitle(projectBody?.title)) { |
|
|
|
NcError.badRequest('Project title already in use'); |
|
|
|
NcError.badRequest('Project title already in use'); |
|
|
|
} |
|
|
|
} |
|
|
|
// todo: sanitize
|
|
|
|
|
|
|
|
|
|
|
|
projectBody.title = DOMPurify.sanitize(projectBody.title); |
|
|
|
projectBody.slug = projectBody.title; |
|
|
|
projectBody.slug = projectBody.title; |
|
|
|
|
|
|
|
|
|
|
|
const project = await Project.createProject(projectBody); |
|
|
|
const project = await Project.createProject(projectBody); |
|
|
@ -391,20 +392,24 @@ export async function projectInfoGet(req, res) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function projectCost(req, res) { |
|
|
|
export async function projectCost(req, res) { |
|
|
|
let cost = 0 |
|
|
|
let cost = 0; |
|
|
|
const project = await Project.getWithInfo(req.params.projectId); |
|
|
|
const project = await Project.getWithInfo(req.params.projectId); |
|
|
|
const sqlClient = NcConnectionMgrv2.getSqlClient(project.bases[0]); |
|
|
|
const sqlClient = NcConnectionMgrv2.getSqlClient(project.bases[0]); |
|
|
|
const userCount = await ProjectUser.getUsersCount(req.query) |
|
|
|
const userCount = await ProjectUser.getUsersCount(req.query); |
|
|
|
const recordCount = (await sqlClient.totalRecords())?.data.TotalRecords |
|
|
|
const recordCount = (await sqlClient.totalRecords())?.data.TotalRecords; |
|
|
|
|
|
|
|
|
|
|
|
if (recordCount > 100000) { // 36,000 or $79/user/month
|
|
|
|
if (recordCount > 100000) { |
|
|
|
cost = Math.max(36000, 948 * userCount) |
|
|
|
// 36,000 or $79/user/month
|
|
|
|
} else if (recordCount > 50000) { // $36,000 or $50/user/month
|
|
|
|
cost = Math.max(36000, 948 * userCount); |
|
|
|
cost = Math.max(36000, 600 * userCount) |
|
|
|
} else if (recordCount > 50000) { |
|
|
|
} else if (recordCount > 10000) { // $240/user/yr
|
|
|
|
// $36,000 or $50/user/month
|
|
|
|
cost = Math.min(240 * userCount, 36000) |
|
|
|
cost = Math.max(36000, 600 * userCount); |
|
|
|
} else if (recordCount > 1000) { // $120/user/yr
|
|
|
|
} else if (recordCount > 10000) { |
|
|
|
cost = Math.min(120 * userCount, 36000) |
|
|
|
// $240/user/yr
|
|
|
|
|
|
|
|
cost = Math.min(240 * userCount, 36000); |
|
|
|
|
|
|
|
} else if (recordCount > 1000) { |
|
|
|
|
|
|
|
// $120/user/yr
|
|
|
|
|
|
|
|
cost = Math.min(120 * userCount, 36000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res.json({ cost }); |
|
|
|
res.json({ cost }); |
|
|
|