|
|
|
@ -100,66 +100,3 @@ export class ProjectsController {
|
|
|
|
|
return project; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
// // Project CRUD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function projectCost(req, res) { |
|
|
|
|
let cost = 0; |
|
|
|
|
const project = await Project.getWithInfo(req.params.projectId); |
|
|
|
|
|
|
|
|
|
for (const base of project.bases) { |
|
|
|
|
const sqlClient = await NcConnectionMgrv2.getSqlClient(base); |
|
|
|
|
const userCount = await ProjectUser.getUsersCount(req.query); |
|
|
|
|
const recordCount = (await sqlClient.totalRecords())?.data.TotalRecords; |
|
|
|
|
|
|
|
|
|
if (recordCount > 100000) { |
|
|
|
|
// 36,000 or $79/user/month
|
|
|
|
|
cost = Math.max(36000, 948 * userCount); |
|
|
|
|
} else if (recordCount > 50000) { |
|
|
|
|
// $36,000 or $50/user/month
|
|
|
|
|
cost = Math.max(36000, 600 * userCount); |
|
|
|
|
} else if (recordCount > 10000) { |
|
|
|
|
// $240/user/yr
|
|
|
|
|
cost = Math.min(240 * userCount, 36000); |
|
|
|
|
} else if (recordCount > 1000) { |
|
|
|
|
// $120/user/yr
|
|
|
|
|
cost = Math.min(120 * userCount, 36000); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
T.event({ |
|
|
|
|
event: 'a:project:cost', |
|
|
|
|
data: { |
|
|
|
|
cost, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
res.json({ cost }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function hasEmptyOrNullFilters(req, res) { |
|
|
|
|
res.json(await Filter.hasEmptyOrNullFilters(req.params.projectId)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default (router) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get( |
|
|
|
|
'/api/v1/db/meta/projects/:projectId/cost', |
|
|
|
|
metaApiMetrics, |
|
|
|
|
ncMetaAclMw(projectCost, 'projectCost') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get( |
|
|
|
|
'/api/v1/db/meta/projects/:projectId/has-empty-or-null-filters', |
|
|
|
|
metaApiMetrics, |
|
|
|
|
ncMetaAclMw(hasEmptyOrNullFilters, 'hasEmptyOrNullFilters') |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
* */ |
|
|
|
|