Merge branch '131-show-missing-shots-in-sequence-reports' into 'devel'

Resolve "Show missing shots in sequence reports"

Closes #131

See merge request wgp/dougal/software!15
This commit is contained in:
D. Berge
2021-09-04 21:32:44 +00:00
4 changed files with 34 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ const html = async function (req, res, next) {
const query = req.query; const query = req.query;
query.sequence = req.params.sequence; query.sequence = req.params.sequence;
const {events, sequences} = await prepare(req.params.project, query); const {events, sequences} = await prepare(req.params.project, query);
const seis = transform(events, sequences, {projectId: req.params.project}); const seis = transform(events, sequences, {projectId: req.params.project, missingAsEvent: true});
const template = (await configuration.get(req.params.project, "sse/templates/0/template")) || defaultTemplatePath; const template = (await configuration.get(req.params.project, "sse/templates/0/template")) || defaultTemplatePath;
// console.log("TEMPLATE", template); // console.log("TEMPLATE", template);

View File

@@ -19,7 +19,7 @@ const pdf = async function (req, res, next) {
const query = req.query; const query = req.query;
query.sequence = req.params.sequence; query.sequence = req.params.sequence;
const {events, sequences} = await prepare(req.params.project, query); const {events, sequences} = await prepare(req.params.project, query);
const seis = transform(events, sequences, {projectId: req.params.project}); const seis = transform(events, sequences, {projectId: req.params.project, missingAsEvent: true});
const template = (await configuration.get(req.params.project, "sse/templates/0/template")) || defaultTemplatePath; const template = (await configuration.get(req.params.project, "sse/templates/0/template")) || defaultTemplatePath;
const html = await render(seis, template); const html = await render(seis, template);

View File

@@ -2,7 +2,8 @@ const { event, sequence, info } = require('../db');
async function prepare (project, query) { async function prepare (project, query) {
const events = await event.list(project, query); const events = await event.list(project, query);
const sequences = await sequence.list(project, query); // Get missing shots by default
const sequences = await sequence.list(project, Object.assign({missing:true}, query));
const equipment = await info.get(null, "equipment"); const equipment = await info.get(null, "equipment");
for (const sequence of sequences) { for (const sequence of sequences) {
const maxTstamp = sequence.ts1_final || sequence.ts1 || +Infinity; const maxTstamp = sequence.ts1_final || sequence.ts1 || +Infinity;

View File

@@ -6,6 +6,7 @@ function transform (events, sequences, opts = {}) {
const exportQC = opts.exportQC !== false; const exportQC = opts.exportQC !== false;
const exportGeneral = opts.exportGeneral !== false; const exportGeneral = opts.exportGeneral !== false;
const exportMissing = opts.exportMissing !== false; const exportMissing = opts.exportMissing !== false;
const missingAsEvent = opts.missingAsEvent;
const output = { const output = {
DglProjectId: opts.projectId, DglProjectId: opts.projectId,
@@ -283,6 +284,35 @@ function transform (events, sequences, opts = {}) {
// endpoint; these are not returned by default. // endpoint; these are not returned by default.
if ("missing_final" in sequence) { if ("missing_final" in sequence) {
SequenceObject.MissingShots = sequence.missing_final.map(s => s.point).sort(); SequenceObject.MissingShots = sequence.missing_final.map(s => s.point).sort();
// Add (pseudo-)events for missing shots
if (missingAsEvent) {
// Create the dummy missing shot events
const pseudoevents = SequenceObject.MissingShots.map( point => {
return {
ShotPointId: point,
EntryType: "Missing shot"
}
});
const isAscending = SequenceObject.Entries[0].ShotPointId <= SequenceObject.Entries[SequenceObject.Entries.length-1].ShotPointId;
pseudoevents.forEach( pseudoevent => {
for (const index in SequenceObject.Entries) {
const ShotPointId = SequenceObject.Entries[index].ShotPointId;
const slotFound = isAscending
? ShotPointId > pseudoevent.ShotPointId
: ShotPointId < pseudoevent.ShotPointId;
if (slotFound) {
SequenceObject.Entries.splice(index, 0, pseudoevent);
break;
}
}
});
}
} }
} }
} }