Project summary: paginate results

This commit is contained in:
D. Berge
2020-08-11 19:35:13 +02:00
parent 09e05388ac
commit f1b2671d90

View File

@@ -8,6 +8,16 @@ async function list () {
async function summary (projectId, opts = {}) {
await pool.query("CALL set_survey($1);", [projectId]);
const sortFields = [
"pid", "name", "lines", "sequences", "unique_shots",
"total_shots", "info"
];
const sortKey = opts.sortBy && sortFields.includes(opts.sortBy) && opts.sortBy || "pid";
const sortDir = opts.sortDesc == "true" ? "DESC" : "ASC";
const offset = Math.abs((opts.page-1)*opts.itemsPerPage) || 0;
const limit = Math.abs(Number(opts.itemsPerPage)) || null;
// FIXME Make this into a PostgreSQL stored procedure
const text = `
SELECT * FROM projects,