mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:37:08 +00:00
Project summary: paginate results
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user