mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:27:07 +00:00
Change default sequence assignment for planned lines.
If there are other lines in the planner, we increment the highest numbered sequence in the planner by one. If there are no planned lines, we take the highest numbered raw sequence and increment by one.
This commit is contained in:
@@ -19,14 +19,20 @@ async function getDistance (client, payload) {
|
||||
}
|
||||
|
||||
async function getSequence (client) {
|
||||
// Get the next free sequence from planned data
|
||||
// if there is any planned lines, if not get the
|
||||
// next available from raw lines
|
||||
const text = `
|
||||
SELECT max(sequence)+1 AS sequence
|
||||
FROM (
|
||||
SELECT sequence
|
||||
FROM raw_lines
|
||||
UNION SELECT sequence
|
||||
FROM planned_lines
|
||||
) t;
|
||||
WITH p AS (
|
||||
SELECT max(sequence) AS sequence
|
||||
FROM planned_lines
|
||||
),
|
||||
r AS (
|
||||
SELECT max(sequence) AS sequence
|
||||
FROM raw_lines
|
||||
)
|
||||
SELECT COALESCE(p.sequence, r.sequence)+1 AS sequence
|
||||
FROM p, r;
|
||||
`;
|
||||
|
||||
const res = await client.query(text);
|
||||
|
||||
Reference in New Issue
Block a user