diff --git a/qiita_db/metadata_template/prep_template.py b/qiita_db/metadata_template/prep_template.py index 77884db17..9899cf729 100644 --- a/qiita_db/metadata_template/prep_template.py +++ b/qiita_db/metadata_template/prep_template.py @@ -1107,3 +1107,28 @@ def current_human_filtering(self, current_human_filtering): WHERE prep_template_id = %s""" qdb.sql_connection.TRN.add(sql, [current_human_filtering, self.id]) qdb.sql_connection.TRN.execute() + + @property + def reprocess_job_id(self): + """The job that was created to reprocess this prep info file + + Returns + ------- + bool or None + The reprocess_job_id of the prep file info + """ + with qdb.sql_connection.TRN: + sql = """SELECT reprocess_job_id + FROM qiita.prep_template + WHERE prep_template_id = %s""" + qdb.sql_connection.TRN.add(sql, [self.id]) + return qdb.sql_connection.TRN.execute_fetchlast() + + @reprocess_job_id.setter + def reprocess_job_id(self, reprocess_job_id): + with qdb.sql_connection.TRN: + sql = """UPDATE qiita.prep_template + SET reprocess_job_id = %s + WHERE prep_template_id = %s""" + qdb.sql_connection.TRN.add(sql, [reprocess_job_id, self.id]) + qdb.sql_connection.TRN.execute() diff --git a/qiita_db/metadata_template/test/test_prep_template.py b/qiita_db/metadata_template/test/test_prep_template.py index bfc72ad62..ea41694fe 100644 --- a/qiita_db/metadata_template/test/test_prep_template.py +++ b/qiita_db/metadata_template/test/test_prep_template.py @@ -1914,6 +1914,21 @@ def test_current_human_filtering(self): pt.current_human_filtering = False self.assertFalse(pt.current_human_filtering) + def test_reprocess_job_id(self): + pt = qdb.metadata_template.prep_template.PrepTemplate(1) + # by default it should be None + self.assertIsNone(pt.reprocess_job_id) + # it should not accept an external_job_id + with self.assertRaises(ValueError): + pt.reprocess_job_id = '124567' + # but it should work fine with an uuid + jid = '6d368e16-2242-4cf8-87b4-a5dc40bb890b' + pt.reprocess_job_id = jid + self.assertEqual(pt.reprocess_job_id, jid) + # and it should be fine to return to its default value + pt.reprocess_job_id = None + self.assertIsNone(pt.reprocess_job_id) + EXP_PREP_TEMPLATE = ( 'sample_name\tbarcode\tcenter_name\tcenter_project_name\t' diff --git a/qiita_db/support_files/patches/92.sql b/qiita_db/support_files/patches/92.sql index 0c2ad5034..a8a7d8bb0 100644 --- a/qiita_db/support_files/patches/92.sql +++ b/qiita_db/support_files/patches/92.sql @@ -22,3 +22,8 @@ ALTER TABLE qiita.slurm_resource_allocations -- Apr 21, 2024 -- Adding a new column: current_human_filtering to qiita.prep_template ALTER TABLE qiita.prep_template ADD current_human_filtering boolean DEFAULT False; + +-- Apr 22, 2024 +-- Adding a new column: reprocess_job_id to qiita.prep_template to keep track of +-- the job that reprocessed this prep +ALTER TABLE qiita.prep_template ADD reprocess_job_id uuid DEFAULT NULL; diff --git a/qiita_db/support_files/qiita-db.dbs b/qiita_db/support_files/qiita-db.dbs index 7e9a970ca..d2cb68131 100644 --- a/qiita_db/support_files/qiita-db.dbs +++ b/qiita_db/support_files/qiita-db.dbs @@ -1001,9 +1001,12 @@ - + + + + @@ -2109,7 +2112,7 @@ $function$ - + @@ -2157,4 +2160,4 @@ FROM qiita.artifact t;]]> - + \ No newline at end of file diff --git a/qiita_db/support_files/qiita-db.html b/qiita_db/support_files/qiita-db.html index 942c14ae8..38d3fe23b 100644 --- a/qiita_db/support_files/qiita-db.html +++ b/qiita_db/support_files/qiita-db.html @@ -2,7 +2,7 @@ -Qiita DB +Qiita Db @@ -65,9 +65,9 @@ +