mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:27:08 +00:00
Save to real_time_inputs also when we're on a line
This commit is contained in:
@@ -10,7 +10,6 @@ async function getAllProjectConfigs () {
|
||||
return `SELECT '${r.schema}' AS schema, data FROM ${r.schema}.file_data WHERE (data->>'archived')::boolean IS NOT true AND data->>'id' IS NOT NULL`;
|
||||
}).join("\nUNION ALL ");
|
||||
|
||||
console.log(text);
|
||||
const res1 = await client.query(text);
|
||||
client.release();
|
||||
return res1.rows.map(r => Object.assign(r.data, {schema: r.schema}));
|
||||
@@ -185,42 +184,38 @@ async function save (navData, opts = {}) {
|
||||
});
|
||||
return obj;
|
||||
}).filter(c => !!c);
|
||||
console.log("CANDIDATES", candidates);
|
||||
// console.log("CANDIDATES", candidates);
|
||||
|
||||
if (candidates.length == 0) {
|
||||
// This is probably a test line, so we treat it as offline
|
||||
console.log("No match");
|
||||
} else if (candidates.length == 1) {
|
||||
// Only one candidate, associate with it
|
||||
console.log("Save into schema", candidates[0].match.schema);
|
||||
} else {
|
||||
// More than one candidate, go for the closest. If more than one active
|
||||
// project with the same preplots, highest numbered schema.
|
||||
console.log("Choose nearest");
|
||||
//
|
||||
const destinationSchema = await getNearestPreplot(candidates);
|
||||
if (destinationSchema) {
|
||||
await saveOnline(candidates.filter(c => c.schema == destinationSchema));
|
||||
if (candidates.length == 1) {
|
||||
// Only one candidate, associate with it
|
||||
// console.log("Save into schema", candidates[0].match.schema);
|
||||
await saveOnline(candidates);
|
||||
navData.payload._schema = candidates[0].match.schema;
|
||||
} else {
|
||||
console.log("Nowhere to save to");
|
||||
// More than one candidate, go for the closest. If more than one active
|
||||
// project with the same preplots, highest numbered schema.
|
||||
// console.log("Choose nearest");
|
||||
const destinationSchema = await getNearestPreplot(candidates);
|
||||
if (destinationSchema) {
|
||||
await saveOnline(candidates.filter(c => c.schema == destinationSchema));
|
||||
navData.payload._schema = destinationSchema;
|
||||
} else {
|
||||
console.log("Nowhere to save to");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Save offline");
|
||||
await saveOffline(navData);
|
||||
navData.payload._sequence = candidates[0].sequence;
|
||||
navData.payload._line = candidates[0].line;
|
||||
navData.payload._point = candidates[0].point;
|
||||
navData.payload._online = true;
|
||||
}
|
||||
}
|
||||
|
||||
// const client = await setSurvey(projectId);
|
||||
//
|
||||
// const text = `
|
||||
// SELECT *
|
||||
// FROM project_summary;
|
||||
// `;
|
||||
//
|
||||
// const res = await client.query(text);
|
||||
// client.release();
|
||||
// return res.rows[0];
|
||||
await saveOffline(navData);
|
||||
}
|
||||
|
||||
module.exports = save;
|
||||
|
||||
Reference in New Issue
Block a user