UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

36 lines (35 loc) 1.27 kB
"use strict"; /* Returns array of such projects, with the following fields: - project_id - title - map from license_id to what is being used right now - last_edited - if project is hidden - project state, e.g., 'running' */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const pool_1 = __importDefault(require("@cocalc/database/pool")); const util_1 = require("@cocalc/database/postgres/util"); const misc_1 = require("@cocalc/util/misc"); async function getProjects(account_id) { if (!(0, misc_1.isValidUUID)(account_id)) { throw Error("invalid account_id -- must be a uuid"); } const pool = (0, pool_1.default)(); // This excludes anything with site_license null or {}. const { rows } = await pool.query(`SELECT project_id, title, site_license, users#>'{${account_id},hide}' as hidden, state#>'{state}' as state, last_edited FROM projects WHERE users ? '${account_id}' AND site_license != '{}' ORDER BY last_edited DESC`, []); (0, util_1.toEpoch)(rows, ["last_edited"]); return rows; } exports.default = getProjects; //# sourceMappingURL=get-projects.js.map