Delete online data before importing sequence.

The deferred import routing will delete any online
data for any raw sequences that it imports.
This commit is contained in:
D. Berge
2020-08-31 13:09:57 +02:00
parent 433daca9ef
commit c4c09f0a9d

View File

@@ -137,7 +137,7 @@ class Datastore:
else:
cur = cursor
qry = "SELECT * FROM files;"
qry = "SELECT * FROM files WHERE hash NOT LIKE '*%';"
cur.execute(qry)
res = cur.fetchall()
@@ -235,6 +235,18 @@ class Datastore:
hash = self.add_file(filepath, cursor)
incr = records[0]["point_number"] <= records[-1]["point_number"]
# Start by deleting any online data we may have for this sequence
# FIXME Factor this out into its own function
qry = """
DELETE
FROM raw_lines rl
USING raw_lines_files rlf
WHERE
rl.sequence = rlf.sequence
AND rlf.hash = '*online*'
AND rl.sequence = %s;
"""
qry = """
INSERT INTO raw_lines (sequence, line, remarks, ntbp, incr)
VALUES (%s, %s, '', %s, %s)
@@ -341,6 +353,20 @@ class Datastore:
hash = self.add_file(filepath, cursor)
incr = p111.point_number(records[0]) <= p111.point_number(records[-1])
# Start by deleting any online data we may have for this sequence
# FIXME Factor this out into its own function
qry = """
DELETE
FROM raw_lines rl
USING raw_lines_files rlf
WHERE
rl.sequence = rlf.sequence
AND rlf.hash = '*online*'
AND rl.sequence = %s;
"""
cursor.execute(qry, (fileinfo["sequence"],))
qry = """
INSERT INTO raw_lines (sequence, line, remarks, ntbp, incr)
VALUES (%s, %s, '', %s, %s)