Import SmartSource header data.

Provided that the SmartSource headers are being
saved to file, and that the path to those files
is present in the survey configuration, we now
import SmartSource information as metadata in
raw_shots.meta->'smsrc'.

Closes #19.
This commit is contained in:
D. Berge
2020-09-06 13:45:56 +02:00
parent c6285e881e
commit 19ce158329
4 changed files with 200 additions and 0 deletions

View File

@@ -438,6 +438,32 @@ class Datastore:
self.maybe_commit()
def save_raw_smsrc (self, records, fileinfo, filepath, filedata = None):
with self.conn.cursor() as cursor:
hash = self.add_file(filepath, cursor)
# Start by deleting any online data we may have for this sequence
# NOTE: Do I need to do this?
#self.del_hash("*online*", cursor)
# The shots should already exist, e.g., from a P1 import
values = [ (json.dumps(record), fileinfo["sequence"], record["shot"]) for record in records ]
qry = """
UPDATE raw_shots
SET meta = jsonb_set(meta, '{smsrc}', %s::jsonb, true)
WHERE sequence = %s AND point = %s;
"""
cursor.executemany(qry, values)
if filedata is not None:
self.save_file_data(filepath, json.dumps(filedata), cursor)
self.maybe_commit()
def save_file_data(self, path, filedata, cursor = None):
"""