From 523ec937ddce2eea877676200bd454222aa3772d Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Tue, 25 May 2021 03:19:42 +0200 Subject: [PATCH] Always merge metadata on import. The INSERT INTO raw_lines / final_lines will not always be executed as the lines may already exist (particularly in raw_lines because of *online*), so whether it worked or not we merge the metadata immediately afterwards (this may cause an extra notification to be fired). --- bin/datastore.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/datastore.py b/bin/datastore.py index 7291f75..15e177b 100644 --- a/bin/datastore.py +++ b/bin/datastore.py @@ -412,6 +412,14 @@ class Datastore: """ cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], ntbp, incr, json.dumps(fileinfo["meta"]))) + + qry = """ + UPDATE raw_lines + SET meta = meta || %s + WHERE sequence = %s; + """ + + cursor.execute(qry, (json.dumps(fileinfo["meta"]), fileinfo["sequence"])) qry = """ INSERT INTO raw_lines_files (sequence, hash) @@ -454,6 +462,14 @@ class Datastore: """ cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], json.dumps(fileinfo["meta"]))) + + qry = """ + UPDATE raw_lines + SET meta = meta || %s + WHERE sequence = %s; + """ + + cursor.execute(qry, (json.dumps(fileinfo["meta"]), fileinfo["sequence"])) qry = """ INSERT INTO final_lines_files (sequence, hash)