mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:37:07 +00:00
getGroup() returns all comparisons.
Just like saveGroup() saves all.
This commit is contained in:
@@ -330,13 +330,16 @@ async function saveGroup (group, opts = {}) {
|
|||||||
|
|
||||||
async function getGroup (groupName, opts = {}) {
|
async function getGroup (groupName, opts = {}) {
|
||||||
|
|
||||||
|
const client = await pool.connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (groupName) {
|
||||||
|
|
||||||
const group = (await groups())?.[groupName]?.map( i => i.pid)?.sort();
|
const group = (await groups())?.[groupName]?.map( i => i.pid)?.sort();
|
||||||
|
|
||||||
if (!group?.length || group?.length < 2) return;
|
if (!group?.length || group?.length < 2) return;
|
||||||
|
|
||||||
const client = await pool.connect();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
const pairs = combinations(group, 2);
|
const pairs = combinations(group, 2);
|
||||||
const flatValues = pairs.flat();
|
const flatValues = pairs.flat();
|
||||||
@@ -355,6 +358,11 @@ async function getGroup (groupName, opts = {}) {
|
|||||||
ORDER BY baseline_pid, monitor_pid
|
ORDER BY baseline_pid, monitor_pid
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
if (!placeholders) {
|
||||||
|
console.log("No pairs found in group");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const res = await client.query(text, flatValues);
|
const res = await client.query(text, flatValues);
|
||||||
if (!res.rows.length) {
|
if (!res.rows.length) {
|
||||||
console.log("Comparison not found in database");
|
console.log("Comparison not found in database");
|
||||||
@@ -369,6 +377,34 @@ async function getGroup (groupName, opts = {}) {
|
|||||||
} else {
|
} else {
|
||||||
return res.rows;
|
return res.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const selectFields = opts.returnData ? 'data, meta' : 'meta';
|
||||||
|
|
||||||
|
const text = `
|
||||||
|
SELECT baseline_pid, monitor_pid, ${selectFields}
|
||||||
|
FROM comparisons.comparisons
|
||||||
|
WHERE type = 'geometric_difference'
|
||||||
|
ORDER BY baseline_pid, monitor_pid
|
||||||
|
`;
|
||||||
|
|
||||||
|
const res = await client.query(text);
|
||||||
|
if (!res.rows.length) {
|
||||||
|
console.log("Comparison not found in database");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.returnData) {
|
||||||
|
return res.rows.map( row => ({
|
||||||
|
...row,
|
||||||
|
data: DougalBinaryBundle.clone(row.data),
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
return res.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user