mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:37:08 +00:00
Remove *all* QC events when saving sequence results.
When saving shot-by-shot results for a sequence, *all* existing QC events for that sequence will be removed first. We do this because otherwise we may end up with QC data for shots that no longer exist. Also, in the case that we have QCed based on raw data, QC results for shots which are not in the final data would stay around even though those shots are no longer valid.
This commit is contained in:
@@ -5,20 +5,16 @@ async function saveShotsQC (projectId, results) {
|
||||
const client = await setSurvey(projectId);
|
||||
await transaction.begin(client);
|
||||
|
||||
async function deleteQCEvent (sequence, shot, qc_id) {
|
||||
// NOTE that we delete from event_log_full
|
||||
// because the event is readonly and we can't otherwise
|
||||
// modify it via event_log (though it'd be nice to)
|
||||
async function deleteQCEvents (sequence) {
|
||||
const text = `
|
||||
DELETE
|
||||
FROM event_log_full
|
||||
WHERE
|
||||
sequence = $1 AND point = $2
|
||||
AND meta->>'qc_id' = $3;
|
||||
WHERE sequence = $1 AND meta ? 'qc_id';
|
||||
`;
|
||||
|
||||
// console.log("DELETE QUERY", projectId, sequence, shot, qc_id);
|
||||
return await client.query(text, [ sequence, shot, qc_id ]);
|
||||
const values = [ sequence ];
|
||||
|
||||
return await client.query(text, values);
|
||||
}
|
||||
|
||||
async function updateQCEvent (sequence, shot, qc_id, result) {
|
||||
@@ -37,11 +33,11 @@ async function saveShotsQC (projectId, results) {
|
||||
};
|
||||
|
||||
for (const sequence in results) {
|
||||
// Remove *all* QC events for this sequence
|
||||
await deleteQCEvents(sequence);
|
||||
for (const shot in results[sequence]) {
|
||||
for (const qc_id in results[sequence][shot]) {
|
||||
const result = results[sequence][shot][qc_id];
|
||||
// Remove any existing event for this QC
|
||||
await deleteQCEvent(sequence, shot, qc_id);
|
||||
if (result !== true) { // `true` means QC passed. Otherwise expect string or array.
|
||||
// Add or replace an existing event for this QC
|
||||
await updateQCEvent(sequence, shot, qc_id, result);
|
||||
|
||||
Reference in New Issue
Block a user