From 963f75fd51e3396d39d68698f4d2eb18c43e5d12 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Sun, 4 Oct 2020 03:49:04 +0200 Subject: [PATCH] Add exporting of missing shots. It is enabled by default but the user should pass `missing=t` (or some other truty value) in the query part of the request. --- lib/www/server/api/middleware/event/list/seis.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/www/server/api/middleware/event/list/seis.js b/lib/www/server/api/middleware/event/list/seis.js index 384a28e..594fab6 100644 --- a/lib/www/server/api/middleware/event/list/seis.js +++ b/lib/www/server/api/middleware/event/list/seis.js @@ -6,6 +6,7 @@ function transform (events, sequences, opts = {}) { const dgl = !!opts.projectId; const exportQC = opts.exportQC !== false; const exportGeneral = opts.exportGeneral !== false; + const exportMissing = opts.exportMissing !== false; const output = { DglProjectId: opts.projectId, @@ -272,6 +273,15 @@ function transform (events, sequences, opts = {}) { SequenceObject.Entries.push(lsp); } } + + // Set the missing shots object if not inhibited by the user. + if (exportMissing) { + // The user also needs to request missing shots from the sequences + // endpoint; these are not returned by default. + if ("missing_final" in sequence) { + SequenceObject.MissingShots = sequence.missing_final.map(s => s.point).sort(); + } + } } return output; @@ -280,7 +290,7 @@ function transform (events, sequences, opts = {}) { const seis = async function (req, res, next) { try { const events = await event.list(req.params.project, req.query); - const sequences = await sequence.list(req.params.project); + const sequences = await sequence.list(req.params.project, req.query); const response = transform(events, sequences, {projectId: req.params.project}); res.status(200).send(response); next();