@cocalc/database
Version:
CoCalc: code for working with our PostgreSQL database
37 lines • 1.37 kB
JavaScript
;
/*
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.site_license_public_info = void 0;
const query_1 = require("../query");
const analytics_1 = require("./analytics");
async function site_license_public_info(db, license_id) {
// Get information about the license itself:
const obj = await (0, query_1.query)({
db,
select: [
"title",
"description",
"expires",
"activates",
"upgrades",
"quota",
"run_limit",
"managers",
],
table: "site_licenses",
where: { id: license_id },
one: true,
});
if (!obj)
throw Error(`no license with id ${license_id}`);
// Get number of runnings projects with this license applied.
obj.running = await (0, analytics_1.number_of_running_projects_using_license)(db, license_id);
// Get number of projects with this license applied (may not be running or actually using license).
obj.applied = await (0, analytics_1.number_of_projects_with_license_applied)(db, license_id);
return obj;
}
exports.site_license_public_info = site_license_public_info;
//# sourceMappingURL=public.js.map