mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 09:47:08 +00:00
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:
@@ -10,7 +10,7 @@ const html = async function (req, res, next) {
|
||||
const query = req.query;
|
||||
query.sequence = req.params.sequence;
|
||||
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;
|
||||
// console.log("TEMPLATE", template);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ const pdf = async function (req, res, next) {
|
||||
const query = req.query;
|
||||
query.sequence = req.params.sequence;
|
||||
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 html = await render(seis, template);
|
||||
|
||||
@@ -2,7 +2,8 @@ const { event, sequence, info } = require('../db');
|
||||
|
||||
async function prepare (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");
|
||||
for (const sequence of sequences) {
|
||||
const maxTstamp = sequence.ts1_final || sequence.ts1 || +Infinity;
|
||||
|
||||
@@ -6,6 +6,7 @@ function transform (events, sequences, opts = {}) {
|
||||
const exportQC = opts.exportQC !== false;
|
||||
const exportGeneral = opts.exportGeneral !== false;
|
||||
const exportMissing = opts.exportMissing !== false;
|
||||
const missingAsEvent = opts.missingAsEvent;
|
||||
|
||||
const output = {
|
||||
DglProjectId: opts.projectId,
|
||||
@@ -283,6 +284,35 @@ function transform (events, sequences, opts = {}) {
|
||||
// endpoint; these are not returned by default.
|
||||
if ("missing_final" in sequence) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user